Inventor API to Change Component of Ipart

Inventor API to Change Component of Ipart

Khoa_NguyenDang
Advocate Advocate
1,850 Views
6 Replies
Message 1 of 7

Inventor API to Change Component of Ipart

Khoa_NguyenDang
Advocate
Advocate

Anyone know how to call this command (Change Component) of iPart in Assembly Environment. 

Change ComponentChange ComponentIt will show this table to choose Part of IpartIt will show this table to choose Part of Ipart

 

Thank guys so much 

 

0 Likes
Accepted solutions (3)
1,851 Views
6 Replies
Replies (6)
Message 2 of 7

marcin_otręba
Advisor
Advisor
Accepted solution

ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyChangeComponentCmd").Execute

 

ipart must be selected.

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

Message 3 of 7

marcin_otręba
Advisor
Advisor
Accepted solution

Sorry not ipart but ipart table must be selected:

 

marcin_otręba_1-1592223994376.png

 

 

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes
Message 4 of 7

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Khoa_NguyenDang 

You'll need to have the Tables node selected and then execute the command "AssemblyChangeComponentCmd".

The most difficult thing will be finding the correct node since it'll change name if you change iPart-row. If you know it's index or if part of the name is always the same it shouldn't be a problem though.

 

If you only have one iPart member in the assembly try this 🙂

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oPane As BrowserPane = oDoc.BrowserPanes.ActivePane
Dim oOcc As ComponentOccurrence
For Each oOcc In oDoc.ComponentDefinition.Occurrences
	If oOcc.IsiPartMember Then Exit For
Next



Dim oNode As BrowserNode = oPane.GetBrowserNodeFromObject(oOcc) 'Get the iParts node.
oNode.Expanded = True
Dim oTableNode As BrowserNode = oNode.BrowserNodes.Item(1) 'Get the tables node.
oTableNode.DoSelect
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyChangeComponentCmd").Execute
Message 5 of 7

Khoa_NguyenDang
Advocate
Advocate

@JhoelForshav 

Thank you so much. It works perfectly

Message 6 of 7

Khoa_NguyenDang
Advocate
Advocate

@marcin_otręba 

You're right. I need to choose the Table to us Change Component 

Thank you so much for your anwser

0 Likes
Message 7 of 7

Khoa_NguyenDang
Advocate
Advocate

@marcin_otręba 

Thank for your solution 

0 Likes