This topic contains 0 replies, has 1 voice, and was last updated by  taner 2 years, 10 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1499

    taner
    Participant

    Hello,

    This code doesnt work after adding input box lines. i want to input r,g,b code by inputbox. But there is an error in this line:

    Selection.Search (“‘Topology’.Face.Color='( ” & r & “, ” & g & “, ” & b & “)’;scr”)

    How can i fix it?

    Code:

    Private Sub CommandButton1_Click()

    Dim Selection1 As Selection

    Dim spabench As SPAWorkbench

    Dim mymeasure As Measurable

    Dim myref As Reference

    Dim myareas As Integer

    Dim InputObjectType()

    Dim partDocument1 As PartDocument

    Dim part1 As Part

    Dim r, g, b As Integer

    Set partDocument1 = CATIA.ActiveDocument

    Set part1 = partDocument1.Part

    Set Selection = CATIA.ActiveDocument.Selection

    r = InputBox(“Write red code color here” & Chr(13), “RED number from RGB code”, r)

    g = InputBox(“Write green code color here” & Chr(13), “GREEN number from RGB code”, g)

    b = InputBox(“Write blue code color here” & Chr(13), “BLUE number from RGB code”, b)

    Selection.Clear

    Selection.Search (“‘Topology’.Face.Color='( ” & r & “, ” & g & “, ” & b & “)’ ;scr”)

    For i = 1 To Selection.Count2

    Set myref = Selection.Item(i).Reference

    Set spabench = partDocument1.GetWorkbench(“SPAWorkbench”)

    Set mymeasure = spabench.GetMeasurable(myref)

    myareas = mymeasure.Area * 10000

    A = Round(myareas, 1)

    Allarea = A + Allarea

    Next i

    MsgBox “Yuzey Alani= ” & Format(Allarea, “0”) & (“cm2”)

    Debug.Print Allarea

    End Sub

    • This topic was modified 2 years, 10 months ago by  taner.
Viewing 1 post (of 1 total)

The forum ‘CATIA Macro Programming’ is closed to new topics and replies.