3. Use DOTNET to save and read data in dmax (part of BIP tool data)

Source: Internet
Author: User
Tags dotnet
1 struct gt_cl_hp_bipxml 2 (3 -- save the data to XML format 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 -- check whether the directory exists 16 (17 --- the first node establishes 18 dotnetnode = xmldocumentxdoc outside. createnode (dotnetclass "system. XML. xmlnodetype "). element) "url: bipdate" "url: Date" 19 dotnetnode. innertext = "" 20 xmldocumentxdoc. appendchild (dotnetnode) 21 22 -- filename = dotnetpath. getfilename (filepath) is not used here, but is added with bippaths data 23 for I in 1 to bippaths. count do 24 (25 --- create string 26 27 28 here --- create element 29 dotnetxmlelement = xmldocumentxdoc. createelement ("Node") 30 dotnetxmlelement. innertext = bippaths [I] --- save the data of the element 31 --- create the property 32 --- 1. BIP name 2. the number of frames starting from 33 bipfilename = dotnetpath. getfilename (bippaths [I]) 34 xmlattributer = xmldocumentxdoc. createattribute ("bipname") 35 xmlattributer. innerxml = bipfilename --- create the first attribute 36 37 -- add the element to the first attribute 38 dotnetxmlelement. setattributenode (xmlattributer) 39 40 --- create the second attribute. The number of frames. // This attribute can be written to 0 frames. You can leave 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 --- above is an element and two attributes to build a model complete below is to insert the node element to the root node 54 --- the first key added to the child should be added under the first element documentelement55 xmldocumentxdoc. documentelement. appendchild (dotnetxmlelement) 56 57) 58 59 --- save the root node and process 60 xmldocumentxdoc. save (filepath) 61) 62 63) 64 65), 66 FN outxml filepath = --- return preferably three arrays one is 67 (68 bipname = # () 69 bipframe = #() 70 bipfilepath = # () 71 --- return node name group return the array of frames returned all paths 72 xmldocumentxdoc = dotnetobject "system. XML. xmldocument "73 xmldocumentxdoc. load filepath74 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)

Usage:

 

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: \ Technical Group salon \ big talk export test file \ ceshi04.max "," J: \ Technical Group salon \ big talk export test file \ ceshi05.max "," J: \ Technical Group salon \ export test file \ ceshi06.max "))

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.