Change imported ipt name in assembly treeview (Inventor api/ vb.net).

Change imported ipt name in assembly treeview (Inventor api/ vb.net).

Anonymous
Not applicable
721 Views
1 Reply
Message 1 of 2

Change imported ipt name in assembly treeview (Inventor api/ vb.net).

Anonymous
Not applicable

Hi,

 

First-off I dont know if ive now posted to the right forum... I am led to belive this is the API forum???

 

The question.. 

 

I import several of my inventor parts (ipt files) into assemblys ussing the following API- vb.net code

 

 

'OPENS TEMPLATE...S            
            oApp = Marshal.GetActiveObject("Inventor.Application")
            oDocs = oApp.Documents
            oDoc = oDocs.Open("C:\TEMPLATE.ipt", True) 'TESTPART1

'SAVE THE TEMPLATE AS NEW IPT FILE...S
                oDoc.SaveAs(TextBox22.Text & "\" & TextBox21.Text &".ipt", False)
                oDoc.Close()

 'IMPORTING THE PART INTO THE CURRENT ASSEMBLY...S
            Dim IAMDOC As AssemblyDocument = oApp.ActiveDocument
            Dim POS As Matrix = oApp.TransientGeometry.CreateMatrix
            Dim NEWocc = IAMDOC.ComponentDefinition.Occurrences.Add(TextBox22.Text & "\" & TextBox21.Text & ".ipt", POS)
            oApp.ActiveView.Update()

 

 

The problem though is the part file which is nolonger named TEMPLATE.ipt but the whatever the value of textbox21 is. will keep the name TEMPLATE in the treeview section... this too must conform with the orriginal value of textbox22 when it was saved...

 

the red arrow in the image shows where the name also needs to append...

 

Naamloos.png

0 Likes
Accepted solutions (1)
722 Views
1 Reply
Reply (1)
Message 2 of 2

Yijiang.Cai
Autodesk
Autodesk
Accepted solution

This is caused by the display name of document. When save copy as another file name, the display name is not changed. When adding this part to assembly, the browser node name of component will be the display name of document. So we need to change the display name of document before save copy as. You could use the code line below -

 

oDoc.DisplayName=TextBox21.Text &".ipt"

oDoc.SaveAs(TextBox22.Text & "\" & TextBox21.Text &".ipt", False)
oDoc.Close(True)

 

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
0 Likes