Hi,
I have no Inventror 2012 at this moment, so cannot test how Inventor 2012 works. But firstly, I do not think this line is correct
oOcc = Component.InventorComponent("Part1:1")
oOcc.Edit
becasue Component.InventorComponent returns the occurrence in the current context. In this case, it is top assembly. While part1:1 is in sub assembly. So I thought it should be
oOcc = Component.InventorComponent(MakePath("subassy","Part1:1"))
oOcc.Edit
this does not work either. But it is not strange to me because the occurrence got by this line is still in the context of sub assembly. While in top assembly, it should be proxy occurrence. So I thought it should be
' Try To Get proxy occurrence In top Assembly
oOcc = Component.InventorComponent("subassy")
oSubOcc = Component.InventorComponent(MakePath("subassy","Part1:1"))
Dim oTempObj As Object
'oOcc.CreateGeometryProxy(oSubOcc,oTempObj) ' failed at this line
Dim oProxyOcc as ComponentOccurrenceProxy
oProxyOcc = oTempObj
oProxyOcc.Edit
Unfortunetly, it failed at CreateGeometryProxy. Finally, I have to use Inventor API directly. i.e. get the occurrence from assembly, instead of using the wrapped functions of iLogic. It works well.
I cannot say if there is problems with InventorComponent. These are what I can see. Hope the final workaround helps you.
'works :
'oOcc = Component.InventorComponent("subassy")
'oOcc.Edit
' does not work
'oOcc = Component.InventorComponent("Part1:1")
'oOcc.Edit
'doesn't work either because the occurrence is in the context of sub assembly
'oOcc = Component.InventorComponent(MakePath("subassy","Part1:1"))
'oOcc.Edit
'Try To Get proxy occurrence In top Assembly
'oOcc = Component.InventorComponent("subassy")
'oSubOcc = Component.InventorComponent(MakePath("subassy","Part1:1"))
'Dim oTempObj As Object
''oOcc.CreateGeometryProxy(oSubOcc,oTempObj) ' failed at this line
' Dim oProxyOcc as ComponentOccurrenceProxy
'oProxyOcc = oTempObj
' oProxyOcc.Edit
' use Inventor API directly
' works!Dim oAssDef As AssemblyComponentDefinition
oAssDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOcc As ComponentOccurrence
oOcc = oAssDef.Occurrences.ItemByName("subassy")
Dim oSubOcc As ComponentOccurrence
'oSubOcc = oOcc.SubOccurrences(1) 'SubOccurrences does not support ItemByName
oSubOcc = oOcc.Definition.Occurrences.ItemByName("Part1:1")
'oSubOcc is in the context of sub assembly
' to edit it in the context of top assembly, need proxy of occurrenceDim oTempObj As Object
oOcc.CreateGeometryProxy(oSubOcc, oTempObj)
Dim oSubOccProxy As ComponentOccurrenceProxy
oSubOccProxy = oTempObj
oSubOccProxy.Edit