Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic rule to change drawing view layer

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Molly15
2226 Views, 9 Replies

iLogic rule to change drawing view layer

Hello all,

 

I am trying to piece togther some code for an ilogic rule. This rule should look for a drawing view that is a flat pattern, if it finds one it should change the object layer to our "CNC" layer.

 

Is this possible?

 

Any suggestions are welcome.

9 REPLIES 9
Message 2 of 10
jdkriek
in reply to: Molly15

If I understand you correctly, this should be the ticket:

 

' JDK 2013
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView
	For Each oView In oSheet.DrawingViews
		' If it's a flatpattern view
		If oView.IsFlatPatternView = True Then
			' Get Layers
			Dim oLayers As LayersEnumerator = oView.Parent.Parent.StylesManager.layers
			' Get CNC layer
			Dim oLayer As Layer = oLayers.Item("CNC")
			' Get lines
			Dim oCurves As DrawingCurvesEnumerator = oView.DrawingCurves()
			Dim oCurve As DrawingCurve
				' For each line
				For Each oCurve In oCurves
					' Change the layer
					oCurve.Segments.Item(1).Layer = oLayer
				Next
		End If
	Next
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 10
Molly15
in reply to: jdkriek

This worked great! Thanks for your help!!

Message 4 of 10
jdkriek
in reply to: Molly15

You're welcome 😉

 

Glad it worked for you.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 10
garrison34
in reply to: Molly15

I used the same rule you provided but, I'm running into issues where is changes all the layers on my flat patterns. I would like my bend lines, centers, and any other layers for my flat to be on there separate layers and change when using this rule. Is there a way to do this?

Message 6 of 10
garrison34
in reply to: jdkriek

I used the same rule you provided but, I'm running into issues where is changes all the layers on my flat patterns. I would like my bend lines, centers, and any other layers for my flat to be on there separate layers and change when using this rule. Is there a way to do this?

Message 7 of 10
dparks2265
in reply to: garrison34

Jordan
Reply Test
Message 8 of 10
wislbaitW3ZMS
in reply to: garrison34

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView

    For Each oView In oSheet.DrawingViews
        ' If it's a flatpattern view
        If oView.IsFlatPatternView = True Then
            If Not (oview.breakoperations.count > 0) Then
            ' Get Layers
            Dim eLayer As LayersEnumerator = oView.Parent.Parent.StylesManager.layers
            ' Get CNC layer
            Dim oLayer As Layer= eLayer.Item("CNC")
            ' Get Visible Layer
            Dim oVisibleLayer As Layer= eLayer.Item("Visible (ANSI)")
            ' Get lines
            Dim oViewCurves As DrawingCurvesEnumerator = oView.DrawingCurves()
            Dim oCurve As DrawingCurve
                ' For each line
                For Each oCurve In oViewCurves
                    ' Change the layer only if it is an object edge
                    If oCurve.Segments.Item(1).Layer Is oVisibleLayer Then
                        oCurve.Segments.Item(1).Layer = oLayer
                    End If
                Next
            End If
        End If
    Next

===============================================================================

Refer to your Drawing Standards setup for which layer your flat pattern is placed
into. If needed, substitute your flat pattern object layer name for the
"Visible (ANSI)" shown above.

 

Message 9 of 10
mike_young
in reply to: wislbaitW3ZMS

Is it possible to adapt this code to change the layer of a line only if the line is 7.99mm long?

 

Also, is it possible to change the layer of a circle only if the circle is 3.99mm dia?

 

I hope so as this would save me a huge amount of time.

Thanks in advance

M


Please mark as Accepted solution
Message 10 of 10
mike_young
in reply to: jdkriek

Is it possible to adapt this code to change the layer of a line only if the line is 7.99mm long?

 

Also, is it possible to change the layer of a circle only if the circle is 3.99mm dia?

 

I hope so as this would save me a huge amount of time.

Thanks in advance

 

M


Please mark as Accepted solution

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report