A program to recognize and reward our most engaged community members
Hi,
If we have a material properties like E, NU, RHO for the steel material, do you any idea how to set the material properties for that steel material in hypermesh with help of TCL script ?
Please help me..
Thanks
Hi @chandrasekhar,
Using the TCL window, material properties can be set using the *setvalue command:
https://help.altair.com/hwdesktop/hwd/topics/reference/hm/_setvalue.htm
For example, if I wanted to change E for material ID 1 from 210000 to 210001:
*setvalue mats id=1 E=210001
Hope this helps!
Adam Reid
Hello @GTT Adam,
Thank you for the reply.
Mr.Adam, i tried using setvalue command to enter the E, Nu, Rho properties to the material with help of tcl script but it's showing some error that values are not considering.
actually my intension is to create a tcl script for creating the material properties and assign them to the components.
for sample checking, i used two different material STEEL, AL and i written script based on these materials but when i try to run the code in hypermesh, it's taking the E,Nu, Rho values.
for your reference, check the below commands.
set material_properties { AL {E 160000 NU 0.31 RHO 9.1E-9} STEEL {E 210000 NU 0.29 RHO 8.5E-9} } if {![info exists material_properties($::material_name)]} { tk_messageBox -message "Invalid material selected!" -type ok return } array set props $material_properties($::material_name) set E $props(E) set NU $props(NU) set RHO $props(RHO) # Check if Material Exists set material_id "" set material_found 0 *createmark mats 1 set material_ids [hm_getmark mats 1] *clearmark mats 1 foreach mat_id $material_ids { set existing_name [hm_getentityvalue mats $mat_id name 1] if {$existing_name eq $::material_name} { set material_id $mat_id set material_found 1 break } } # Create Material if Not Found if {!$material_found} { if {[catch {*createentity mats cardimage=MAT1 name=$::material_name} err]} { tk_messageBox -message "Error creating material: $err" -type ok return } set material_id [hm_latestentityid mats 0] # Assign Material Properties foreach {key value} [list E $E NU $NU RHO $RHO] { if {[catch {*setvalue mats id=$material_id $key $value} err]} { tk_messageBox -message "Error setting $key for material: $err" -type ok return } } }
please help me how to fix the issue.
Thank you
If the syntax I provided is used in a TCL script, it works as intended. Therefore, the error is in the remainder of your implementation. If the shown TCL script is loaded into HyperMesh with the material Custom_Steel defined, it executes as desired:
What errors are you receiving specifically?
Hello @GTT Adam ,
when i try to use the setvalue option for loading the material properties (E,Nu, Rho) with help of tcl script, the young's modules has assigned properly but NU & RHO are showing some error is "invalid set name or numeric code NU & RHO" please find the below code for your reference.
set materialName "Steel" set youngsModulus 210000 ;# Young's modulus in MPa set poissonsRatio 0.33 ;# Poisson's ratio set density 7.85e-9 ;# Density in tonne/mm^3
*createmark materials 1 "all" *createmark properties 1 "all" *createentity materials name=$materialName cardimage=MAT1 *setvalue materials name=$materialName id=1
*setvalue materials id=1 STATUS=1 1 ;# Activate the material *setvalue materials id=1 E=$youngsModulus *setvalue materials id=1 NU=$poissonsRatio *setvalue materials id=1 RHO=$density please correct it if anything in the above tcl script.
Hello @chandrasekhar
There are a couple of very minor things to modify to make your code work 1. The error that you get "invalid set name or numeric code NU & RHO" is because the attribute names are case sensitive. In your case you are able to set the E values but not NU or RHO. The attribute names are "Nu and Rho". Changing this would update the value. To know the list of available attributes, use https://help.altair.com/hwdesktop/hwd/topics/reference/hm/hm_attributelist.htm
"invalid set name or numeric code NU & RHO"
2. The option STATUS needs to be used for individual attributes to make sure that these attributes are enabled. Valid values are 0 (attribute is off), 1 (attribute is on) or 2 (attribute is always on). Notice that STATUS must be capitalized.
Summing up the above changes, the below code might work
# Define material properties set materialName "Steel" set youngsModulus 210000 ;# Young's modulus in MPa set poissonsRatio 0.33 ;# Poisson's ratio set density 7.85e-9 ;# Density in tonne/mm^3 # Create a new material *createentity material name=$materialName cardimage=MAT1 *setvalue material name=$materialName E=$youngsModulus STATUS=1 *setvalue material name=$materialName Nu=$poissonsRatio STATUS=1 *setvalue material name=$materialName Rho=$density STATUS=1