Check if an assembly/set is already available in a model

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hello guys,

 

I am new here and have less experience in scripting. I hope you can help me.  image/emoticons/default_smile.png' alt=':)' srcset='/emoticons/smile@2x.png 2x' width='20' height='20'>

My problem is the following one. I would like to check if an assembly and a set are already available in a model. I want do it by the assembly/set name.

For example, I want to to check if the assembly with the name xx is already available. When no, a new assembly is created. When yes, nothing is done.

Which command lines I have to use doing it? Thanks.

 

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    Try this code:


    set assyName 'Toto';
    if { [hm_entityinfo exist assems $assyName -byname] == 1 } {
    puts 'Assy $assyName exists!'
    } else {
    puts 'Assy $assyName not found!'
    }

    Just change 'assems' to 'sets' for checking overs Sets.

     

    HTH,

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2014

    That helps. Thanks.  image/emoticons/default_smile.png' alt=':)' srcset='/emoticons/smile@2x.png 2x' width='20' height='20'>