Creating surface property by TCL scripts

stefht85
stefht85 Altair Community Member

I have 4 components and i want associate 4 different generical property names by a TCL script. I created TCL just to create component but i cannot be able to assign property names by TCL.

image.png

Best Answer

  • Cesar_Rivas1
    Cesar_Rivas1 Altair Community Member
    Answer ✓

    hi there….

    try the following, there is no checks and some assumptions. Hope it solves what you need…

    set comp_list [ hm_entitylist comps id ]; #gets all comps and loop thru them.

    foreach comp_id $comp_list {

    #gets current name and color.
    set comp_name [ hm_getvalue comps id=$comp_id dataname=name ]
    set color [ hm_getvalue comps id=$comp_id dataname=color ]

    # create a new prop with the componentn name/id/color
    *createentity props id=$comp_id name="$comp_name" cardimage=PSHELL color=$color
    set last_id [ hm_latestentityid props ]

    #assigns the new property to the component 'comp_id'
    *setvalue comps id=$comp_id propertyid={props $last_id}

    }

Answers

  • Cesar_Rivas1
    Cesar_Rivas1 Altair Community Member
    Answer ✓

    hi there….

    try the following, there is no checks and some assumptions. Hope it solves what you need…

    set comp_list [ hm_entitylist comps id ]; #gets all comps and loop thru them.

    foreach comp_id $comp_list {

    #gets current name and color.
    set comp_name [ hm_getvalue comps id=$comp_id dataname=name ]
    set color [ hm_getvalue comps id=$comp_id dataname=color ]

    # create a new prop with the componentn name/id/color
    *createentity props id=$comp_id name="$comp_name" cardimage=PSHELL color=$color
    set last_id [ hm_latestentityid props ]

    #assigns the new property to the component 'comp_id'
    *setvalue comps id=$comp_id propertyid={props $last_id}

    }

  • stefht85
    stefht85 Altair Community Member

    Dear

    Cesar_Rivas1

    It's works well, thanks for help me!

    Best regards

    Stefano

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.