Import XML file to several parts

Import XML file to several parts

berry.lejeune
Advocate Advocate
935 Views
2 Replies
Message 1 of 3

Import XML file to several parts

berry.lejeune
Advocate
Advocate

Hi all,

 

I've made an xml file from some parameters from a part. I know how to import this file into a new part so these parameters will show up in the new part. But is it also possible to do this in 300+ parts all at once?

0 Likes
936 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor

I don't know there is some API function similar to the Import/Export parameters to XML file.

You have two possibilities:

  1. Export parameters to the XML and then create some XML reader and create/update parameters using standard API functions. It can be little bit hard task for beginners.
  2. Create external iLogic rule where you can "Capture Current state" and it generates part of the code where it sets the values for the parameters. But the parameters must exist. Also you can create similar code block to create missing parameters. 

In my opinion the second option is better, but it depends on your planed workflow.

MichaelNavara_0-1673352168224.png

 

0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Hi @berry.lejeune  & @Michael.Navara.  There is actually a fairly simple iLogic line of code for importing & exporting the parameters to & from XML file.  See the following two lines:

 

iLogicVb.Automation.ParametersXmlSave(oDoc, XMLFileName, XmlSaveOption.All)
iLogicVb.Automation.ParametersXmlLoad(oDoc, XMLFileName)

 

Of course, in this example the oDoc variable, and the XMLFileName variable would have to be declared and their values set before that point, and there are three options to the XmlSaveOption, which is an Enum (All, KeysOnly, & None).

Edit:  Here are the online help links for those two methods:  ParametersXmlSave & ParametersXmlLoad

The documentation also says that you should supply the full file path of the XML file, not just its name, in case that was not clear.  And logic would suggest that the document you supply as the first input variable should be the Inventor document that you want the parameters to be imported into, or exported from.  And if setting the XMLSaveOption to KeysOnly when exporting, make sure you check the checkbox for those parameters under the 'Export Parameter' column, so they will be recognized, before attempting to export them by code.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)