Auto assign properties using TCL script
Hi,
I want to write a script that auto assign pre-existing properties, materials and element types (ANSYS Profile) to components based on the component name. For example: if I have properties, material and ET already created as 2mm, steel, shell181 and my component name is '2mm@Steel_plate' I want the script to read the component name search the characters before '@', match it with the similarly named property and assign it to the component. Similarly for material and ET.
I am new to TCL scripting. I tried doing it manually in HM and read the command.tcl file. However the command file contains only commands based on the ID as shown below.
*startnotehistorystate {Modified Type of component from 0 to 1} *setvalue comps id=1 STATUS=2 3081={sensors 1} *endnotehistorystate {Modified Type of component from 0 to 1} *startnotehistorystate {Modified Property of component from 0 to 1} *setvalue comps id=1 propertyid={props 1} *endnotehistorystate {Modified Property of component from 0 to 1} *startnotehistorystate {Modified Material of component from 0 to 1} *setvalue comps id=1 materialid={mats 1} *endnotehistorystate {Modified Material of component from 0 to 1}
Here is a link to a screen grab of the HM tree. https://imgur.com/a/zz72Tj2
Please point me in the right direction.
Answers
-
You can get comp name from comp ID by using the following code:
set compname [hm_entityinfo name components $comp_id]
For matching comp name, use 'regexp' (https://www.tcl.tk/man/tcl8.4/TclCmd/regexp.htm)
0