Automated property definition based on a component name [TCL code]
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 /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
Answers
-
Hi Jakub,
You can get commands and relevant information from HyperMesh reference guide.
0 -
Altair Forum User said:
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 /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,
0 -
Altair Forum User said:
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).
0