Hi @aspecchio
In order to use a plane that is not in a first level component you have to create a proxy for that plane and use that.
See code below. You can use the function provided to create a proxy for a plane how deep down you want by passing an agrument as a string of the "path" to the occurrence containing the plane, separated by "¤" and one argument for the name of the plane.
If you're not writing in iLogic, you cant use "ThisDoc.Document" for the main assembly, so that has to be changed to ActiveDocument or whatever in that case...
In the code below it is PlaneProx you should use to create the constraint.
Sub Main
Dim PlaneProx As WorkPlaneProxy = CreatePlaneProxy("Assembly1¤AsmPart1", "AsmPart1Plane1")
End Sub
Function CreatePlaneProxy(occString As String, oWPName As String) As Object
Dim occList As New List(Of ComponentOccurrence)
Dim occArr() As String = occString.Split("¤")
For i = 0 To occArr.Length - 1
If i = 0 Then
occList.Add(ThisDoc.Document.ComponentDefinition.Occurrences.ItemByName(occArr(i)))
Else
occList.Add(occList.Item(i - 1).Definition.Occurrences.ItemByName(occArr(i)))
End If
Next
Dim oProx As Object
For i = occList.Count - 1 To 0 Step -1
If i = occList.Count - 1
Call occList(i).CreateGeometryProxy(occList(i).Definition.WorkPlanes.Item(oWPName), oProx)
Else
Call occList(i).CreateGeometryProxy(oProx, oProx)
End If
Next
Return oProx
End Function
Hope this helps!