Here is an example from the API help samples..
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Get references to the two occurrences to constrain.
' This arbitrarily gets the first and second occurrence.
Dim oOcc1 As ComponentOccurrence
oOcc1 = oAsmCompDef.Occurrences.Item(1)
Dim oOcc2 As ComponentOccurrence
oOcc2 = oAsmCompDef.Occurrences.Item(2)
' Get the XY plane from each occurrence. This goes to the
' component definition of the part to get this information.
' This is the same as accessing the part document directly.
' The work plane obtained is in the context of the part,
' not the assembly.
Dim oPartPlane1 As WorkPlane
oPartPlane1 = oOcc1.Definition.WorkPlanes.Item(3)
Dim oPartPlane2 As WorkPlane
oPartPlane2 = oOcc2.Definition.WorkPlanes.Item(3)
' Because we need the work plane in the context of the assembly
' we need to create proxies for the work planes. The proxies
' represent the work planes in the context of the assembly.
Dim oAsmPlane1 As WorkPlaneProxy
Call oOcc1.CreateGeometryProxy(oPartPlane1, oAsmPlane1)
Dim oAsmPlane2 As WorkPlaneProxy
Call oOcc2.CreateGeometryProxy(oPartPlane2, oAsmPlane2)
' Create the constraint using the work plane proxies.
Call oAsmCompDef.Constraints.AddMateConstraint(oAsmPlane1, oAsmPlane2, 0)
-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570
Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269