For Hypermesh: OptiStruct profile: TCL macro for duplicating the assigned property to a component and renaming the duplicated property to the component name.

Dhee
Dhee Altair Community Member
edited March 21 in Community Q&A

For Hypermesh: OptiStruct profile:
Please suggest a tcl macro for the following.

  1. For each component whose ID starts from 10001, check the assigned property.
  2. Duplicate the assigned property.
  3. Rename the duplicated property with the component name.
  4. Renumber the duplicated property ID with the component ID.
  5. Assign this property to the component.

Reason for doing this:

  • Properties with correct thicknesses (and material for most components) are already assigned in the existing model. But the property name is very generic (example: shell_2mm, shell_3mm, etc)

 

In the end, I want a unique property with correct thickness for each component.

Kindly let me know if more details are required.

Note: After this operation, I will have another requirement of fetching correct material name for each component from an external excel sheet. Will try this later.

Answers

  • Dhee
    Dhee Altair Community Member
    edited March 20

    Here is the one working for component ID starting from 10001 to 11200:

    set lst_compName [hm_complist id];
     
    foreach n_compId $lst_compName {
    puts $n_compId---nCompId
    if {$n_compId >= 10001 && $n_compId <= 11200} {
    set nPropId [hm_getvalue comps id=$n_compId dataname=property.id];
    set str_compName [hm_getvalue comps id=$n_compId dataname=name];
    set n_solverId [lindex [hm_getsolverid property $nPropId] 0];
    #duplicate
    puts "B4 dumplicate"
    *createentitysameas properties $nPropId;
    puts "Aftr duplicate"
    #
    *createmark property 1 -1
    set NewProp [hm_getmark property 1];
    puts $NewProp---newProp
    #assign the same compid to new created propid
    puts $NewProp---$n_compId--b4
    *setvalue props id=$NewProp id={props $n_compId}
    puts $NewProp---$n_compId--afttr
     
    set str_newName [list "PP" $str_compName]
    puts [join $str_newName "_"]--newNameB4
    *setvalue props id=$NewProp name=[join $str_newName "_"]
    puts [join $str_newName "_"]--newNameBaftr
    # assignmen of property to the component
    puts "B4 assignment"
    *setvalue comps id=$n_compId propertyid={props $NewProp}
    puts "atr assignment"
    # *setvalue comps id=5001 propertyid={props 60059}
    } else {
    continue;
    }
     
    }