zoukankan      html  css  js  c++  java
  • 3dmax 中使用dotnet 对数据保存读取 (bip工具数据一部分)

     1 struct gt_cl_hp_bipxml 
     2 (
     3     -- 把数据保存成 xml 格式
     4     fn  bipXml   bipPaths   frames    filePath= 
     5         
     6     (
     7         if bipPaths.count >0 then 
     8         (
     9             XmlDocumentXDoc =  dotNetobject    "System.Xml.XmlDocument"
    10             dotnetPath = dotNetClass "System.IO.Path" 
    11             dotnetDirectory =dotNetClass "System.IO.Directory"
    12             dotnetFile = dotNetClass "System.IO.File"
    13             DirFile =dotnetPath.GetDirectoryName (filePath)
    14             
    15             if dotnetDirectory.Exists (DirFile) then   --尊在不存在都要进行  这里应该判断目录是不是存在 
    16             (
    17                 --- 第一个节点在外边建立
    18                 dotnetNode =  XmlDocumentXDoc.CreateNode  ((dotNetClass "System.Xml.XmlNodeType").Element)   "Url:bipdate"   "Url:date"
    19                 dotnetNode.InnerText =""
    20                 XmlDocumentXDoc.AppendChild (dotnetNode)
    21         
    22                 --fileName = dotnetPath.GetFileName(filePath) 这里不是用于到这里 而是加入bipPaths 数据
    23                 for i in 1 to  bipPaths.count  do 
    24                 (
    25                     --- 在这里建立字符串 
    26                     
    27                     
    28                     ---建立元素
    29                     dotnetXmlElement = XmlDocumentXDoc.CreateElement("node")
    30                     dotnetXmlElement.InnerText = bipPaths[i]--- 元素的数据进行保存处理 
    31                     --- 建立属性
    32                     ---1. bip的名称 2.开始的帧数 
    33                     bipFileName = dotnetPath.GetFileName(bipPaths[i])
    34                     XmlAttributer = XmlDocumentXDoc.CreateAttribute ("bipname")
    35                     XmlAttributer.InnerXml = bipFileName ---建立第一个属性
    36                     
    37                     -- 元素加入第一个属性
    38                     dotnetXmlElement.SetAttributeNode  (XmlAttributer)
    39                     
    40                     ---建立第二个属性帧数 //该属性可写入0 帧 可以不写
    41                     if frames.count ==0 then 
    42                     (
    43                         XmlAttributerFrame = XmlDocumentXDoc.CreateAttribute("frame")
    44                         XmlAttributerFrame.InnerXml = "0" 
    45                         dotnetXmlElement.SetAttributeNode   XmlAttributerFrame  
    46                         
    47                     )else 
    48                     (
    49                         XmlAttributerFrame = XmlDocumentXDoc.CreateAttribute("frame")
    50                         XmlAttributerFrame.InnerXml = frames[i] as string 
    51                         dotnetXmlElement.SetAttributeNode   XmlAttributerFrame  
    52                     )
    53                     --- 上面是一个元素两个属性建立模型完成 下面就是把 节点元素 插入到 根节点中
    54                     ---上面一键加入了子 应该是在第一个元素下加入 DocumentElement
    55                     XmlDocumentXDoc.DocumentElement.AppendChild (dotnetXmlElement)
    56                         
    57                 )
    58                 
    59                 --- 组后对根节点进行保存处理
    60                 XmlDocumentXDoc.save(filePath)
    61             )
    62 
    63         )
    64         
    65     ),
    66     fn outXml  filePath =  --- 返回最好是三个数组 一个是
    67     (
    68         bipname =#()
    69         bipFrame =#()
    70         bipFilePath =#()
    71         --- 返回节点名称组 返回帧的数组 返回全部路径
    72         XmlDocumentXDoc = dotNetObject  "System.xml.XmlDocument"
    73          XmlDocumentXDoc.load  filePath
    74          root = XmlDocumentXDoc.DocumentElement;
    75         if root.HasChildNodes then 
    76         (
    77              SysXmlNodeList = root.ChildNodes  ;
    78             for i in 0 to SysXmlNodeList.count-1 do 
    79             (
    80                     Append bipname  ((SysXmlNodeList.Item(i)).GetAttribute "bipname")
    81                     append  bipFrame (((sysXmlNodeList.Item(i)).GetAttribute "frame") as Integer)
    82                         Append  bipFilePath      ((sysXmlNodeList.Item(i)). InnerText )
    83                 
    84             )
    85         )
    86 
    87         return #( bipname ,bipFrame ,bipFilePath)    
    88             
    89         
    90     )
    91 )

     使用方法:

    op= gt_cl_hp_bipxml()

      op.bipxml ui #()"d://op.xml"

    undefined

    op.outxml "d://op.xml"

    #(#("ceshi04.max", "ceshi05.max", "ceshi06.max"), #(0, 0, 0), #("j:\技术组沙龙\大话导出测试文件\ceshi04.max", "j:\技术组沙龙\大话导出测试文件\ceshi05.max", "j:\技术组沙龙\大话导出测试文件\ceshi06.max"))

  • 相关阅读:
    script标签加载顺序(defer & async)
    nginx反向代理vue访问时浏览器加载失败,出现 ERR_CONTENT_LENGTH_MISMATCH 问题
    Git每次进入都需要输入用户名和密码的问题解决
    update select
    sql --- where concat
    GO -- 正则表达式
    浏览器中回车(Enter)和刷新的区别是什么?[转载]
    转: Linux --- Supervisor的作用与配置
    Golang 使用Map构建Set类型的实现方法
    linux -- 查看应用启动时间
  • 原文地址:https://www.cnblogs.com/gaitian00/p/2949880.html
Copyright © 2011-2022 走看看