Inventor Layers and line types

Inventor Layers and line types

tschaeferZNBXX
Advisor Advisor
1,343 Views
8 Replies
Message 1 of 9

Inventor Layers and line types

tschaeferZNBXX
Advisor
Advisor

Before I get racked over the coals, yes I know this is a little backwards thinking!

 

My question is does anyone know a way to get still show line types if I am using layers in Inventor?  I am looking for a way to still show a view in a certain color but also have the visible and hidden line types.

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
1,344 Views
8 Replies
Replies (8)
Message 2 of 9

mcgyvr
Consultant
Consultant

@tschaeferZNBXX wrote:

Before I get racked over the coals, yes I know this is a little backwards thinking!

 

My question is does anyone know a way to get still show line types if I am using layers in Inventor?  I am looking for a way to still show a view in a certain color but also have the visible and hidden line types.


Your 2nd sentence got a little confusing but based on the 3rd one is this what you are asking for?

A way to just change the color of all linework (be it solid or hidden or whatever) for a particular view...

base view and 2 projected views shown here.. 

layerscolors.PNG



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 9

tschaeferZNBXX
Advisor
Advisor

Yes that is correct.  I am using this code below to update all the views on multiple sheets but the different line types come in as solid lines.

 

SyntaxEditor Code Snippet

Sub Main 
    ' Get the active drawing document. 
    Dim oDoc As DrawingDocument 
    oDoc = ThisApplication.ActiveDocument 
    
    Dim oSheets As Sheets
    oSheets = oDoc.Sheets
    Dim oSheet As Sheet
    
    'get current sheet so it can
    'be made active again later
    Dim oCurrentSheet As Sheet
    oCurrentSheet = oDoc.ActiveSheet    
    
    Dim oViews As DrawingViews
    Dim oView As DrawingView
    
    ' Iterate through the sheets
    For Each oSheet In oSheets
    '    activate the sheet
        oSheet.Activate
        
        'get the collection of view on the sheet
        oViews = oSheet.DrawingViews        
        
        ' Iterate through the views on the sheet
        For Each oView In oViews    
            
            Dim docDesc As DocumentDescriptor 
            docDesc = oView.ReferencedDocumentDescriptor  
            
            ' Verify that the drawing view is of an assembly. 
            If docDesc.ReferencedDocumentType <> kAssemblyDocumentObject Then 
                Continue For
            End If  
            
            ' Get the component definition for the assembly. 
            Dim asmDef As AssemblyComponentDefinition 
            asmDef = docDesc.ReferencedDocument.ComponentDefinition  
            
            ' Process the view, wrapping it in a transaction so the 
            ' each view can be undone with a single undo operation. 
            Dim trans As Transaction 
            trans = ThisApplication.TransactionManager.StartTransaction( _ 
                                    oDoc, "Change drawing view color")  
            
            ' Call the recursive function that does all the work. 
            Call ProcessAssemblyColor(oView, asmDef.Occurrences) 
            trans.End 
        Next
        'update the sheet
        oSheet.Update
    Next
    
    'return to original sheet    
    oCurrentSheet.Activate
End Sub 



Private Sub ProcessAssemblyColor(drawView As DrawingView, _ 
                                 Occurrences As ComponentOccurrences) 
   ' Iterate through the current collection of occurrences. 
   Dim occ As ComponentOccurrence 
   For Each occ In Occurrences 
      ' Check to see if this occurrence is a part or assembly. 
      If occ.DefinitionDocumentType = kPartDocumentObject Then 
         ' ** It's a part so process the color.  

         ' Get the render style of the occurrence. 
         Dim color As RenderStyle 
         Dim sourceType As StyleSourceTypeEnum 
         color = occ.GetRenderStyle(sourceType)  

         ' Get the TransientsObjects object to use later. 
         Dim transObjs As TransientObjects 
         transObjs = ThisApplication.TransientObjects  

         ' Verify that a layer exists for this color. 
         Dim layers As LayersEnumerator 
         layers = drawView.Parent.Parent.StylesManager.layers  

         Dim oDoc As DrawingDocument 
         oDoc = drawView.Parent.Parent  

         On Error Resume Next 
         Dim colorLayer As Layer 
         colorLayer = layers.Item(color.Name)  

         If Err.Number <> 0 Then 
            On Error Goto 0 
            ' Get the diffuse color for the render style. 
            Dim red As Byte 
            Dim green As Byte 
            Dim blue As Byte  

            ' Create a color object that is the diffuse color. 
            Call color.GetDiffuseColor(red, green, blue) 
            Dim newColor As color 
            newColor = transObjs.CreateColor(red, green, blue)  

            ' Copy an arbitrary layer giving it the name 
            ' of the render style. 
            colorLayer = layers.Item(1).Copy(color.Name) 

            ' the attributes of the layer to use the color, 
            ' have a solid line type, and a specific width. 
            colorLayer.Color = newColor 
            colorLayer.LineType = kContinuousLineType 
            colorLayer.LineWeight = 0.02 
         End If 
         On Error Goto 0  

         ' Get all of the curves associated with this occurrence. 
         On Error Resume Next 
         Dim drawcurves As DrawingCurvesEnumerator 
         drawcurves = drawView.DrawingCurves(occ) 
         If Err.Number = 0 Then 
            On Error Goto 0  

            ' Create an empty collection. 
            Dim objColl As ObjectCollection 
            objColl = transObjs.CreateObjectCollection()  

            ' Add the curve segments to the collection. 
            Dim drawCurve As DrawingCurve 
            For Each drawCurve In drawcurves 
               Dim segment As DrawingCurveSegment 
               For Each segment In drawCurve.Segments 
                  objColl.Add (segment)
               Next 
            Next  

            ' Change the layer of all of the segments. 
            Call drawView.Parent.ChangeLayer(objColl, colorLayer) 
         End If 
         On Error Goto 0 
      Else 
         ' It's an assembly so process its contents. 
         Call ProcessAssemblyColor(drawView, occ.SubOccurrences) 
      End If 
   Next 
End Sub
Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 4 of 9

mcgyvr
Consultant
Consultant

oh and now a mention of code...better late than never I guess

Smiley Tongue

 

Busy now.. 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 5 of 9

tschaeferZNBXX
Advisor
Advisor

Hey just want to keep you guys and gals busy.  

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 6 of 9

Anonymous
Not applicable

As if we don't have enough on our plates already...;)

0 Likes
Message 7 of 9

tschaeferZNBXX
Advisor
Advisor

@mcgyvr have you had a chance to look at this or can you guide me to the answer?

 

I am assuming that the answer is adding a line in the iLogic to change the hidden line type to the same layer as the model just not sure how to do this.

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes
Message 8 of 9

mcgyvr
Consultant
Consultant

@tschaeferZNBXX wrote:

@mcgyvr have you had a chance to look at this or can you guide me to the answer?

 

I am assuming that the answer is adding a line in the iLogic to change the hidden line type to the same layer as the model just not sure how to do this.


@tschaeferZNBXX This one is out of my league due to the ilogic coding....  I'm sure it must be possible as I can manually/easily change the color of the line work but I don't know that ilogic stuff well enough in this situation to be of any help..  Sorry.. 

 

Is there a reason you are changing the layer and not just changing the color of the curves?



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 9 of 9

tschaeferZNBXX
Advisor
Advisor

@mcgyvr no worries, thank you for trying.  

 

Our customers require AutoCAD files with Layers as a deliverable when we finish a project.  We currently spend a lot of time doing this at the end of a project to get this completed from Inventor.  We are trying to get this changed but it can be difficult to get things changed quickly so the idea was to use this as a gap closer.

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
0 Likes