hypermesh create entity "if file exists"

Suslu
Suslu Altair Community Member
edited May 2021 in Community Q&A

Hi all 

 

I am creating comps with for loop, however i really dont know how to catch error in TCL.

I want to skip the error " A component by that name already exists in database"

Regards

for {set i 10} {$i <20} {incr i} {

*createentity comps name=pshell.$i id=$i
if { [catch {set $i [expr $i + 1] }] } {

set $i [expr $i + 1]
}
}

 

Best Answer

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited May 2021 Answer ✓

    there is command 'hm_entityinfo exist'

     

    An example checking if some SET exists, below. If not, it is created.

            if { [hm_entityinfo exist sets "$name" -byname] ==1 } {
                #else
            } else {
                *createentity sets cardimage=SET_ELEM includeid=0 name=$name
                *setvalue sets name=$name STATUS=0 5422=LIST
            }

Answers

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited May 2021 Answer ✓

    there is command 'hm_entityinfo exist'

     

    An example checking if some SET exists, below. If not, it is created.

            if { [hm_entityinfo exist sets "$name" -byname] ==1 } {
                #else
            } else {
                *createentity sets cardimage=SET_ELEM includeid=0 name=$name
                *setvalue sets name=$name STATUS=0 5422=LIST
            }

  • Suslu
    Suslu Altair Community Member
    edited May 2021

    Hi Adriano

    Thanks for your answer. Before your answer, i marked all comps and compare with each one. :)

    Regards