COLOR CHANGE FOLDING LINE

COLOR CHANGE FOLDING LINE

analistacad
Contributor Contributor
913 Views
6 Replies
Message 1 of 7

COLOR CHANGE FOLDING LINE

analistacad
Contributor
Contributor

Hi friends
Can someone help me, how to create an ilogic rule to change the double lines UP BLUE and DOWN RED in Inventor planes?

 

I WANT THE LINE TO ALSO CHANGE COLOR

Thanks

 

 

0 Likes
Accepted solutions (2)
914 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

Maybe this is what you need:

Sub Main()
    Dim doc As DrawingDocument = ThisDoc.Document

    ChangeLayer(doc, DrawingEdgeTypeEnum.kBendUpEdge, "ARRIBA")
    ChangeLayer(doc, DrawingEdgeTypeEnum.kBendDownEdge, "ABAJO")
End Sub

Private Sub ChangeLayer(doc As DrawingDocument, EdgeType As DrawingEdgeTypeEnum, layerName As String)
    Dim layer As Layer = doc.StylesManager.Layers.Item(layerName)

    Dim segments = doc.Sheets.Cast(Of Sheet).
        SelectMany(Function(sheet) sheet.DrawingViews.Cast(Of DrawingView)).
        SelectMany(Function(view) view.DrawingCurves.Cast(Of DrawingCurve)).
        Where(Function(curve) curve.EdgeType = EdgeType).
        SelectMany(Function(curve) curve.Segments.Cast(Of DrawingCurveSegment)).
        ToList()

    For Each segment As DrawingCurveSegment In segments
        segment.Layer = layer
    Next
End Sub

Edit:

improved the rule

Jelte de Jong
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


Blog: hjalte.nl - github.com

Message 3 of 7

analistacad
Contributor
Contributor

Uff !!! Excellent work friend !! Thanks
- A question for version 2017 is it possible?
- It is possible to leave a single rule see image

 

- What should I study to have ilogic proficiency?

 

Thanks friend Great help a greeting from
Colombia  😃🙏🤝

0 Likes
Message 4 of 7

analistacad
Contributor
Contributor

Hello

Friend Jelte DeJong

 

I get this error, see image

 

Error in rule 3, in document: SER1-00-A00.idw
Cannot find the public member "Cast" in the type Sheets

 

greeting

0 Likes
Message 5 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

In the code, I use the LINQ library. I'm not sure if that library is already available in Inventor 2017.  This is the same rule only without the helper functions from the LINQ library.

Sub Main()
    Dim doc As DrawingDocument = ThisDoc.Document

    ChangeLayer(doc, DrawingEdgeTypeEnum.kBendUpEdge, "ARRIBA")
    ChangeLayer(doc, DrawingEdgeTypeEnum.kBendDownEdge, "ABAJO")
End Sub

Private Sub ChangeLayer(doc As DrawingDocument, EdgeType As DrawingEdgeTypeEnum, layerName As String)
    Dim layer As Layer = doc.StylesManager.Layers.Item(layerName)

    For Each sheet As Sheet In doc.Sheets
        For Each view As DrawingView In Sheet.DrawingViews
            For Each curve As DrawingCurve In View.DrawingCurves
                If (curve.EdgeType = EdgeType) Then
                    For Each segment As DrawingCurveSegment In curve.Segments
                        segment.Layer = layer
                    Next
                End If
            Next
        Next
    Next
End Sub

Jelte de Jong
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


Blog: hjalte.nl - github.com

0 Likes
Message 6 of 7

analistacad
Contributor
Contributor

Friend, I am very grateful to you, thank you very much, it already worked for me!😃

 

 

from Colombia a cordial greeting

0 Likes
Message 7 of 7

analistacad
Contributor
Contributor

Friend, I am very grateful to you, thank you very much, it already worked for me!

from Colombia a cordial greeting

0 Likes