Change component iPart

Change component iPart

Anonymous
Not applicable
785 Views
4 Replies
Message 1 of 5

Change component iPart

Anonymous
Not applicable
I've a routine made in VB6 which inserts and constains a iPart in a assembly. Now I want to call the Change Component command which shows the dialog to change a ipart component. See attached file.
I tried this with "AssemblyEditComponentCtxCmd"
But that don't work. What's the right commandname for this?
I use INV 2009

Dim oControlDef As ControlDefinition
oINVapp.ActiveDocument.SelectSet.Select oOcc1
Set oControlDef = oINVapp.CommandManager.ControlDefinitions.Item("AssemblyEditComponentCtxCmd")
oControlDef.Execute
0 Likes
786 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Just to clarify, what you want is to be able to launch the 'Change
Component' command and NOT perform the change operation, correct? If it's
the latter the ComponentOccurrence.ChangeRowOfiPartMember API can be used.

If you just want to launch the command, the command name is
"AssemblyChangeComponentCmd". However, you need to have the 'Table" node
under the occurrence (and not the occurrence itself) selected for the launch
to work. Since there isn't an API object for the table node, selecting it is
not straightforward. You need to use a browser API workaround as shown
below. The code assumes that the name of the table node is "Table" and is
not localized.

Sanjay-


Sub ChangeComponentCommand()

Dim oAssembly As AssemblyDocument
Set oAssembly = ThisApplication.ActiveDocument

Dim oCompDef As AssemblyComponentDefinition
Set oCompDef = oAssembly.ComponentDefinition

Dim oOcc As ComponentOccurrence
Set oOcc = oCompDef.Occurrences.Item(1)

Dim oNode As BrowserNode
Set oNode = GetBrowserNodeFromObject(oAssembly, oOcc)

Dim oTableNode As BrowserNode
Set oTableNode = oNode.BrowserNodes.Item("Table")

oAssembly.SelectSet.Clear
oTableNode.DoSelect

Dim oControlDef As ControlDefinition
Set oControlDef =
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyChangeComponentCmd")

oControlDef.Execute

End Sub

Private Function GetBrowserNodeFromObject(ByVal oDoc As Document, ByVal
oObject As Object) As BrowserNode

' Get the browser node definition associated with the object.
Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition
Set oNativeBrowserNodeDef =
oDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oObject)

' Get the top browser node of the model pane.
Dim oTopBrowserNode As BrowserNode
Set oTopBrowserNode = oDoc.BrowserPanes.ActivePane.TopNode

' Get the browser node.
' This assumes that only one node references the browser node
definition.
Set GetBrowserNodeFromObject =
oTopBrowserNode.AllReferencedNodes(oNativeBrowserNodeDef).Item(1)

End Function
0 Likes
Message 3 of 5

Anonymous
Not applicable
First sorry I respond so late but I'm just back from holiday.

Thanks Sanjay your code does just what I needed.
Only I had to put one line to your code:
oTableNode.Expanded = True

otherwise it didn't work for me.

Best Regards,

Geert
0 Likes
Message 4 of 5

Anonymous
Not applicable
I just put my code sample which works fine in a vb6.exe, in a vb6.dll which I use as a addin in INV2009 and now the line
oTableNode.DoSelect doesn't work anymore. So the next command ("AssemblyChangeComponentCmd") doesn't work either. Why is that?

Geert
0 Likes
Message 5 of 5

Anonymous
Not applicable

Does anyone know if there is a way to make this work in 2019 version?

0 Likes