Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
dean.morrison
in reply to: Anonymous

Matt,

 

I do a similar thing (import to inventor from xml)

 

My xml format may be slightly different, but here is some of the code that i use.

I use VBA to do this - example below.

I hope you can figure out what you need to change, based on this example.

 

Dean.

-----------------------------------------------------------------------------

 

'I have a reference to Microsoft XML v3.0

 

xmlfile = "C:\xml.xml" 'Path to xml file

Set objXML = New MSXML2.DOMDocument

objXML.Load xmlfile

 

'For a normal node

Set xmlElem = objXML.selectSingleNode("//NodeName")
If Not xmlElem Is Nothing Then
oNodeName = xmlElem.Text
End If

 

'For a node with children

Set xmlElem = objXML.selectNodes("//NodeNamewithchildren")
If Not xmlElem Is Nothing Then
oNodeNamewithchildren = xmlElem.ChildNodes.Item(0).Text 'index for child node
End IF


'To apply the xml node value to a User Paramater

Dim oFileLocations As FileLocations
Set oFileLocations = ThisApplication.FileLocations

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Open(oFileLocations.Workspace & "/Part.ipt")

Dim oPartCompDef As PartComponentDefinition
Set oPartCompDef = oPartDoc.ComponentDefinition

Dim oParams As UserParameters
Set oParams = oPartCompDef.Parameters.UserParameters

oParams.Item("ParameterName").Expression = oNodeName

oParams.Item("ParameterName").Expression = oNodeNamewithchildren

oPartDoc.Save2 (True)
oPartDoc.Close