Assign the material properties

chandrasekhar
chandrasekhar Altair Community Member

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

Tagged:

Answers

  • GTT Adam
    GTT Adam
    Altair Employee

    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

  • chandrasekhar
    chandrasekhar Altair Community Member

    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.

    Define Material Properties
    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

  • GTT Adam
    GTT Adam
    Altair Employee

    Hi @chandrasekhar,

    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?

    Hope this helps!

    Adam Reid

  • chandrasekhar
    chandrasekhar Altair Community Member

    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.

    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

    *createmark materials 1 "all"
    *createmark properties 1 "all"
    *createentity materials name=$materialName cardimage=MAT1
    *setvalue materials name=$materialName id=1

    Assign material properties

    *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.

    Thank you