Geometry Proxies for using work features in a lower level document, I think.
oCylEdge1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Select the lower most limit of the cylinder bore (Think insert constraint)")
oCylEdge2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Select the lower most limit of the piston rod (Think insert constraint)")
For Each oWorkPlane In oCylEdge1.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
oWorkPlane.Visible=True
Next
oCylOrigPlane1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select the origin plane of the cylinder")
For Each oWorkPlane In oCylEdge1.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
oWorkPlane.Visible=False
Next
For Each oWorkPlane In oCylEdge2.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
oWorkPlane.Visible=True
Next
oCylOrigPlane2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select the a co-planar origin plane of the rod")
For Each oWorkPlane In oCylEdge2.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
oWorkPlane.Visible=False
Next
Dim oCompDef1 As ComponentDefinition = oCylOrigPlane1.Parent()
Dim oCompDef2 As ComponentDefinition = oCylOrigPlane2.Parent()
Dim oCompOcc1 As ComponentOccurrence = oAsmCompDef.Occurrences.AllReferencedOccurrences(oCompDef1).Item(1)
Dim oCompOcc2 As ComponentOccurrence = oAsmCompDef.Occurrences.AllReferencedOccurrences(oCompDef2).Item(1)
oCompOcc1.CreateGeometryProxy(oCylOrigPlane1, oAsmPlane1)
oCompOcc2.CreateGeometryProxy(oCylOrigPlane2, oAsmPlane2)
oMate1 = oAsmCompDef.Constraints.AddMateConstraint(oAsmPlane1, oAsmPlane2, 0)
With oMate1
.Name = "COINCIDENT PLANE"
.Offset.Expression = "0 in"
.Suppressed = False
End With
There is an example of using proxies/making constraints. It was necessary to create the proxies to be able to access the PARTS Origin planes for use in constrains in the top level ASSEMBLY (directly up 1 level from them).
Good luck!
Edit: Looking at my methods, it is kind of convoluted because of the Pick method that I deemed necessary for my process. However, to use the proxies, all you need is the Occurrence containing the workfeatures, and the workfeatures themselves. So it might be easier for you.
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.