Automated property definition based on a component name [TCL code]

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

Hello,

 

I'd like to write a script for HyperMesh which automatically generates properties and assigns material to a component.

The article Automation for Material and Property Values in HyperMesh Using TCL inspired me enough to make my life easier image/emoticons/default_smile.png' alt=':)' srcset='/emoticons/smile@2x.png 2x' width='20' height='20'>

 

The idea is similar to that one, described in the article. I'd like to put information about material and thickness in my component name. The only thing I don't know is where can I find commands which could read and analyse my components name.

 

I.e:

 

COMPONENT_NAME@MATERIAL_THICKNESS (my component name)

Main_Hood@steel_12mm

 

I'd like to split the name of component into variables:

NAME = Main_Hood (everything before '@' sign is a name)

MATERIAL = steel

THICKNESS = 12

 

Could you suggest me where could I search for such commands?

 

Thank you in advance.

 

Best regards

Jakub

 

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2015

    Hi Jakub,

     

    You can get commands and relevant information from HyperMesh reference guide.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2015

    Hello,

     

    I'd like to write a script for HyperMesh which automatically generates properties and assigns material to a component.

    The article Automation for Material and Property Values in HyperMesh Using TCL inspired me enough to make my life easier image/emoticons/default_smile.png' alt=':)' srcset='<fileStore.core_Emoticons>/emoticons/smile@2x.png 2x' width='20' height='20'>

     

    The idea is similar to that one, described in the article. I'd like to put information about material and thickness in my component name. The only thing I don't know is where can I find commands which could read and analyse my components name.

     

    I.e:

     

    COMPONENT_NAME@MATERIAL_THICKNESS (my component name)

    Main_Hood@steel_12mm

     

    I'd like to split the name of component into variables:

    NAME = Main_Hood (everything before '@' sign is a name)

    MATERIAL = steel

    THICKNESS = 12

     

    Could you suggest me where could I search for such commands?

     

    Thank you in advance.

     

    Best regards

    Jakub

     

    Maybe my following code could give you an idea ?

    *createmark comps 1 all

    set mycomps [ hm_getmark comps 1 ]

    hm_markclear comps 1

    foreach i $mycomps {

    set compname [hm_entityinfo name components $i]

    if { [regexp {(.*)@(.*)_(.*)} $compname matched name mat thickness] == 1 } {

    puts 'Name = $name ; Mat= $mat; Thickness= $thickness'

    }

    }

    See my screenshot too.

     

    HTH,

    <?xml version="1.0" encoding="UTF-8"?>post-889-0-46329300-1446126896_thumb.png

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2015

    Maybe my following code could give you an idea ?

    *createmark comps 1 all

    set mycomps [ hm_getmark comps 1 ]

    hm_markclear comps 1

    foreach i $mycomps {

    set compname [hm_entityinfo name components $i]

    if { [regexp {(.*)@(.*)_(.*)} $compname matched name mat thickness] == 1 } {

    puts 'Name = $name ; Mat= $mat; Thickness= $thickness'

    }

    }

    See my screenshot too.

     

    HTH,

     

    Thank you very much.

    I'm very glad to read the code because at the end I did it in a very similar way (with a split command instead of regular expressions).