Let’s Start Programming! Forums CATIA Macro Programming body name based on iteration number inside a loop

This topic contains 1 reply, has 1 voice, and was last updated by  Vivien 3 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1321

    Vivien
    Participant

    Hello,

    I won’t go into the specifics of what I am working on,
    in a loop I create a body each iteration, so the name change each iteration (“body.2”, “body.3”, “body.4” and so on)
    as I work inside each iteration with the body created I need to be able to set a variable to the current body whose name is changing depending on the iteration number

    Set body2workon = bodies1.Item("Body.3")

    I’d like to replace the “3” with a value that changes each iteration (step.Value)

    I guess I need to convert the numeric value to string, then concatenate “Body.” with the sting, and send it to “Item”

    I tried :

    but it doesn’t seem to work, only 1rst iteration works
    (I’d like to point out that other parts of the script are tested and functionnal, the script work with a fix body number)

    thank you for your help

    • This topic was modified 3 years, 1 month ago by  Vivien.
    • This topic was modified 3 years, 1 month ago by  Vivien.
    #1324

    Vivien
    Participant

    Nevermind,

    bodynumber = step.Value+2
    bodyname = “Body.”&bodynumber
    Set body2workon = bodies1.Item(bodyname)

    it works, the error comes from another script

Viewing 2 posts - 1 through 2 (of 2 total)

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