Autodrawing color

Autodrawing color

m.maertens6DTZT
Enthusiast Enthusiast
175 Views
1 Reply
Message 1 of 2

Autodrawing color

m.maertens6DTZT
Enthusiast
Enthusiast

Hi,

 

We're using a macro to generate automaticly a drawing and each page contains a different sub-assembly. 
During this action, we also create a visual difference between our structure and the connectors that are used. This is by using the macro autocolor (see below). It creates an overlay on the connectors - so they are more visible in an assembly.
The filter for the structure of for the connectors is by looking to the full name. But I want to filter on the Category - Inventor Document Summary Information. 
The category can be "Parts" or "Frames" 

Anyone knows how I can filter on the property "Category"?

Public Sub AutoColorForMacro()
'step -1 declare stuff
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet

'step 0 traverse true drawing activating the sheets and auto colouring them
Dim i As Integer
i = 3
For i = 3 To oDrawDoc.Sheets.Count
    Set oSheet = oDrawDoc.Sheets.Item(i)
    oSheet.Activate
    oDrawDoc.Update


' step 1 get drawingview
  Dim oDrawView As DrawingView
  Set oDrawView = oSheet.DrawingViews.Item(1)
  
'step 2 Get the active assmbly of the drawing view.
  Dim oDocDesc As DocumentDescriptor
  Set oDocDesc = oDrawView.ReferencedDocumentDescriptor

  Dim oAssyDoc As AssemblyDocument
  Set oAssyDoc = oDocDesc.ReferencedDocument

'step 2,5 set activate BOMview with all levels 15/07/2014
    Dim oBOM As BOM
    Set oBOM = oAssyDoc.ComponentDefinition.BOM
    
    oBOM.StructuredViewEnabled = True
    oBOM.StructuredViewFirstLevelOnly = True
  
'step 3 Create / activate Design view "Parts"
    Dim oDVParts As DesignViewRepresentation
        On Error Resume Next
    Set oDVParts = oAssyDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Parts")
        If err Then
        Set oLODParts = oAssyDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add("Parts")
        End If
    oDVParts.Activate

'step 4 filter required docs for "Parts"
  Dim oRefDocs As DocumentsEnumerator
  Set oRefDocs = oAssyDoc.AllReferencedDocuments

  Dim oDoc As Inventor.Document
  For Each oDoc In oRefDocs
    'selection criteria
    If InStr(oDoc.FullFileName, "aaaa") Or _
    InStr(oDoc.FullFileName, "bbbb") Or _
    InStr(oDoc.FullFileName, "xxxx") Or _
   InStr(oDoc.FullFileName, sDefaultRootProject) Then
   
      'find all occurrences for every part found
      Dim oOccEnum As ComponentOccurrencesEnumerator
      Set oOccEnum = oAssyDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc)
      Dim oOcc As ComponentOccurrence
      For Each oOcc In oOccEnum
	  
        oOcc.Visible = False
           
            
        Next 'oOcc
    End If 'selecetion criteria
  Next  'oDoc
  
'step 5 activate master Designview
    Dim oDVMaster As DesignViewRepresentation
    Set oDVMaster = oAssyDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Master")
    oDVMaster.Activate
  
'step 6 Create / activate Design view "Frames"
    Dim oDVFrames As DesignViewRepresentation
        On Error Resume Next
    Set oDVFrames = oAssyDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Frames")
        If err Then
        Set oDVFrames = oAssyDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add("Frames")
        End If
    oDVFrames.Activate

'step 7 filter required docs for "Frames"
  For Each oDoc In oRefDocs
    'selection criteria
   If InStr(oDoc.FullFileName, "aaaa") Or _
    InStr(oDoc.FullFileName, "bbbb") Or _
    InStr(oDoc.FullFileName, "xxxx") Or _
    InStr(oDoc.FullFileName, sDefaultRootProject) Then

           oOcc.Visible = True
        End If
             
        Next 'oOcc
        End If
    Else
      'find all occurrences for every part found
      Set oOccEnum = oAssyDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc)
      For Each oOcc In oOccEnum
      oOcc.Visible = False
        'exeption for boxscreen 16/09/2015
            If InStr(oDoc.FullFileName, "727 25 0202") Then
            oOcc.Visible = True
            End If
        Next 'oOcc
    End If 'selecetion criteria
  Next  'oDoc
  
'step 8 activate master view
    oDVMaster.Activate

'step 9 add a positional representation (needed to create an overlay)
    Dim oPos As PositionalRepresentation
    Set oPos = oAssyDoc.ComponentDefinition.RepresentationsManager.PositionalRepresentations.Add("4Macro")
    Set oPos = oAssyDoc.ComponentDefinition.RepresentationsManager.PositionalRepresentations.Item("Master")
    oPos.Activate
    
'Step 10 change designview to "frames"
    'first set to master to get good updates
    Call oDrawView.SetDesignViewRepresentation("Master", False)
    Call oDrawView.SetDesignViewRepresentation("Frames", True)

'step 11 create an overlay
    'check if an old version exists & delete it
    Dim oDrawViewCheck As DrawingView
    For Each oDrawViewCheck In oSheet.DrawingViews
        If oDrawViewCheck.Name = "Parts" Then
            If oDrawViewCheck.ParentView.Name = oDrawView.Name Then
            Call oDrawViewCheck.Delete
            End If
        End If
    Next
    
    Dim oOverlayView As DrawingView
    Set oOverlayView = oSheet.DrawingViews.AddOverlayView(oDrawView, "Master", "Parts", True, kHiddenLineRemovedDrawingViewStyle, False, "Parts")

'step 12 go to the next page
Next

End Sub



 

0 Likes
176 Views
1 Reply
Reply (1)
Message 2 of 2

Curtis_Waguespack
Consultant
Consultant

Hi @m.maertens6DTZT 

 

Here is a quick iLogic example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisDoc.Document
oRefDocs = oAssyDoc.AllReferencedDocuments
Dim oDoc As Document
For Each oDoc In oRefDocs oCategory = oDoc.PropertySets.Item _ ("Inventor Document Summary Information").Item("Category") MsgBox(oCategory.Value,,"iLogic") Next

 

 

 

EESignature

0 Likes