Select by color

Select by color

edhess
Enthusiast Enthusiast
4,509 Views
7 Replies
Message 1 of 8

Select by color

edhess
Enthusiast
Enthusiast

I have a part, as a single body, where I've changed a lot of faces to a different color. I changed it to a color that I don't really want, and now want to select all of those same faces to change them again. Is there a quick way to filter out and select only the colored faces I changed, so I don't have to re-select them all one by one?

 

In AutoCAD I could use the Quick Select by color to do this, so I'm wondering if there's any similar tools in Inventor.

 

If there isn't a tool to do so, can iLogic be used to do anything like this?

0 Likes
Accepted solutions (2)
4,510 Views
7 Replies
Replies (7)
Message 2 of 8

admaiora
Mentor
Mentor

Hi Ed,

 

you can't.

 

I wnat that too.

 

http://forums.autodesk.com/t5/inventor-ideas/material-appearance-select-components-with-same-materia...

Admaiora
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.

_____________________________________________________________________________
Facebook | Twitter | Youtube

Message 3 of 8

HermJan.Otterman
Advisor
Advisor
Accepted solution

Hello Edhess,

 

I made an iLogic rule for you that will select all faces with the same color (name).

first select one face, that run the rule. it will select every face, within the part, with the same color.

just put the code in a new iLogic rule, select a face, and run the rule.

 

 

    'first select ONE face with a different color, than start this rule
    
    Private Sub Main()

        Dim oPartDoc As Inventor.PartDocument = ThisApplication.ActiveDocument
        Dim oSelectSet As SelectSet = oPartDoc.SelectSet
        Dim oFaceColor As String = ""


        If oSelectSet.Count <> 1 Then
            MsgBox("Select one face, than start this rule")
            Exit Sub
        End If

        Dim oSelectedFace As Face = oSelectSet.Item(1)
        Dim oFaceColorFound As Boolean = False

        oFaceColor = findFaceColor(oSelectedFace)

        If oFaceColor = "NoColor" Then
            MsgBox("No color found")
            Exit Sub
        End If

        Dim oFaces As Faces = oPartDoc.ComponentDefinition.SurfaceBodies(1).Faces
        Dim oFace As Face
        For Each oFace In oFaces
            Dim oOtherFaceColor As String = findFaceColor(oFace)
            If oOtherFaceColor = oFaceColor Then
                oSelectSet.Select(oFace)
            End If
        Next

    End Sub


    Private Function findFaceColor(ByVal oFace As Face) As String
        Dim result As String = ""

        If oFace.AttributeSets.Count > 0 Then
            For Each oAttribset As AttributeSet In oFace.AttributeSets
                For Each oAttribute As Attribute In oAttribset
                    If oAttribute.Name = "FaceColor" Then
                        result = oAttribute.Value
                        'oFaceColorFound = True
                        Exit For
                    End If
                Next
            Next
        Else
            result = "NoColor"
        End If

        Return result
    End Function

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 4 of 8

Cadmanto
Mentor
Mentor
Accepted solution

 

Take a look at this thread to see if it helps you.

 

iLogic Rule for changing faces

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 5 of 8

edhess
Enthusiast
Enthusiast

HermJan, that iLogic rule does exactly what I was looking for.

 

Cadmanto, the rule in that link worked as well in a somewhat different way, however, I'm running into the same problem they had where it can only be used once. Still helpful though, and I'll look into it more once I'm more familiar with iLogic.

 

admaiora, voted for your idea request.

 

Thank you all for your help.

0 Likes
Message 6 of 8

dehicka
Explorer
Explorer

It does not work on imported STEP models. 

findFaceColor always returns NoColor.

0 Likes
Message 7 of 8

dehicka
Explorer
Explorer

Simple example model in the attachment.

Looks like there are no FaceColor attribute set on any face (the have no attributes at all), but they indeed have a color. 

0 Likes
Message 8 of 8

HermJan.Otterman
Advisor
Advisor

sorry for the Very late reaction...

 

the  FindFaceColor function can be simplified and it will work than also with the .stp

 

replace the FindFaceColor function with this:

 

Private Function findFaceColor(ByVal oFace As Face) As String
        Dim result As String = ""
	Try
result = oFace.Appearance.Name Catch End Try Return result End Function

 

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes