Sherlock Homies
Sherlock Homies

Reputation: 162

Selecting a Catia part in a for loop

There is a small error in my For loop as it will not select the part that I want to color. I used a variable hash to put all the names of the document there and then tried the Catia function to color, but still got nothing!

Below is a part fo the code. Problem zone is the Select Case. It wont actually select and color the part if found.

UPDATE: now i know exactly where the problem is, it is inside case during selection of the part and coloring it. somehow it wont even select the part.

For n = 1 To DokAnzahl
    Set Dokument = DokumentArray(n)

    ReDim DokumentArrayNew(DokAnzahl)
    DokumentArrayNew(n)  = CStr(Dokument.Name)

    For j = 1 To UBound(arrNamen)
        If arrNamenNew(j) = Left(DokumentArrayNew(n), Len(arrNamenNew(1))) Then
            'MsgBox "They are equal!"
            hash = DokumentArrayNew(n)
            ColorCode(j) = arrFarben(j)
            'MsgBox ColorCode(j) checked

            m = j+1

            Select Case ColorCode(j)
                Case "NEU" 'rot
                    Set sel = catia.activedocument.selection
                    sel.search "Name =hash,all"
                    sel.visproperties.setRealColor 240, 1, 1, 1
                Case "entfällt" 'Gelb
                    Set sel = catia.activedocument.selection
                    sel.search "Name =hash,all"
                    sel.visproperties.setRealColor 240, 240, 16, 1
                Case "COP" 'Grün
                    Set sel = catia.activedocument.selection
                    sel.search "Name =hash,all"
                    sel.visproperties.setRealColor 30, 240, 60, 1
                Case Else
                    MsgBox "no color info"
            End Select
        End If
    Next
Next

Upvotes: 1

Views: 4072

Answers (1)

Quima
Quima

Reputation: 914

Your Selection.Search is searching for the word "Hash" and not what is inside the variable hash

Change your Select Case statements to this:

Set sel = catia.activedocument.selection
sel.search "Name =*" & hash & "*,all"

Upvotes: 1

Related Questions