Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Inventor API to Change Component of Ipart

Khoa_NguyenDang
Advocate

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
Reply
Accepted solutions (3)
1,050 Views
6 Replies
Replies (6)

marcin_otręba
Advisor
Advisor
Accepted solution

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

 

ipart must be selected.

marcin_otręba
Advisor
Advisor
Accepted solution

Sorry not ipart but ipart table must be selected:

 

marcin_otręba_1-1592223994376.png

 

 

0 Likes

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

Khoa_NguyenDang
Advocate
Advocate

@JhoelForshav 

Thank you so much. It works perfectly

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

Khoa_NguyenDang
Advocate
Advocate

@marcin_otręba 

Thank for your solution 

0 Likes