Automatically show reference planes in drawing views in Sub Assemblies **

Automatically show reference planes in drawing views in Sub Assemblies **

Tiffany_Hayden_
Collaborator Collaborator
503 Views
1 Reply
Message 1 of 2

Automatically show reference planes in drawing views in Sub Assemblies **

Tiffany_Hayden_
Collaborator
Collaborator

I found this code in a previous post concerning Automatically show reference plans in drawing views and it works for what it was wrote for. But I would like to go down to the next level where I have two sub assemblies and turn on the reference planes at that level. Can anyone tell me or give me a direction of what needs to change to do that? 

 

Thank you in advance. 

 

    Dim oDwgDoc As DrawingDocument
    Set oDwgDoc = ThisApplication.ActiveDocument
   
    Dim oSht As Sheet
    Set oSht = oDwgDoc.ActiveSheet
   
    Dim oDwgView As DrawingView
    Set oDwgView = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select view to show the origin plane")
    Dim oWP As WorkPlane
   
    If oDwgView.ReferencedDocumentDescriptor.ReferencedDocumentType = kPartDocumentObject Then
        Dim oPartDoc As PartDocument
        Set oPartDoc = oDwgView.ReferencedDocumentDescriptor.ReferencedDocument
       
        Dim oPartCompDef As PartComponentDefinition
        Set oPartCompDef = oPartDoc.ComponentDefinition
       
        For Each oWP In oPartCompDef.WorkPlanes
            oWP.AutoResize = True
            On Error Resume Next
            Call oDwgView.SetIncludeStatus(oWP, True)
        Next
    Else
        Dim oAssyDoc As AssemblyDocument
        Set oAssyDoc = oDwgView.ReferencedDocumentDescriptor.ReferencedDocument
       
        Dim oAssyCompDef As AssemblyComponentDefinition
        Set oAssyCompDef = oAssyDoc.ComponentDefinition
       
        For Each oWP In oAssyCompDef.WorkPlanes
            oWP.AutoResize = True
            On Error Resume Next
            Call oDwgView.SetIncludeStatus(oWP, True)
        Next
    End If

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Accepted solutions (1)
504 Views
1 Reply
Reply (1)
Message 2 of 2

Tiffany_Hayden_
Collaborator
Collaborator
Accepted solution

I found a solution. 

 

    Dim oAssyDoc As AssemblyDocument
    Set oAssyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    
    Dim oComponentOccs As ComponentOccurrences
    Set oComponentOccs = oAssyDoc.ComponentDefinition.Occurrences
    
    Dim oCompOcc As ComponentOccurrence
    
    Dim oSubOccs As ComponentOccurrences
    Dim oSubOcc As ComponentOccurrence
    

    For Each oCompOcc In oAssyDoc.ComponentDefinition.Occurrences
        'Looking for normal BOM structure for C models that are not reference.
        If oCompOcc.BOMStructure = kNormalBOMStructure Then
           Set oSubOccs = oCompOcc.Definition.Occurrences
           For Each oSubOcc In oSubOccs
           
                Dim oPlane As WorkPlane
                'Finding the YZ Plane in the sub assemblies C models
                Set oPlane = GetDocWPl(oSubOcc.Definition.Document, "YZ Plane")
                'Making a Plane Proxy for the sub assembly C model
                Dim oPlaneProx As WorkPlaneProxy
                Call oSubOcc.CreateGeometryProxy(oPlane, oPlaneProx)
                
                'Proxy Plane for the Final Assembly D Model
                Dim oPlane_oAssy As WorkPlane
                Call oCompOcc.CreateGeometryProxy(oPlaneProx, oPlane_oAssy)
                oView.SetIncludeStatus oPlane_oAssy, True

            Next
           
        End If
    Next
    
    

 

 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes