Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi @martin_winkler 

If you want to include the plane from partfiles named "testfile.ipt" you could just traverse all LeafOccurrences in the assembly. I think this should be enough to get the result you want :slightly_smiling_face:

 

Sub SetIncludeStatusFromAsm()
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    Dim oView As DrawingView
    Set oView = oSheet.DrawingViews(1)
    Dim oAsm As AssemblyDocument
    Set oAsm = oView.ReferencedDocumentDescriptor.ReferencedDocument
    Dim intWorkplane As Integer
    intWorkplane = 1
    Dim strFileName As String
    strFileName = "testfile.ipt"
    Dim oOcc As ComponentOccurrence
    Dim oDoc As Document
    For Each oOcc In oAsm.ComponentDefinition.Occurrences.AllLeafOccurrences
        Set oDoc = oOcc.ReferencedDocumentDescriptor.ReferencedDocument
        If Right(oDoc.FullFileName, Len(oDoc.FullFileName) - InStrRev(oDoc.FullFileName, "\")) = strFileName Then
            Dim oWP As WorkPlane
            Set oWP = oDoc.ComponentDefinition.WorkPlanes(intWorkplane)
            Dim oWPprox As WorkPlaneProxy
            Call oOcc.CreateGeometryProxy(oWP, oWPprox)
            Call oView.SetIncludeStatus(oWPprox, True)
        End If
    Next
End Sub