TCL SCRIPT FOR VOLUME OF COMPS

Felippe Oliveira
Felippe Oliveira Altair Community Member
edited September 2 in Community Q&A

Hello,

I would like to know how to use a tcl code to get the volume of each comp I have in my model and export as a list in a excel file.

Thanks!

Answers

  • SunnyZhang
    SunnyZhang
    Altair Employee
    edited September 2

    Hi, 

    hm_getmass can be used to get the volume of a component with id $comp_id: 

    *createmark comps 1 $comp_id
    set temp [hm_getmass comps 1]
    set mass [lindex $temp 0]
    set <strong>vol </strong>[lindex $temp 1]
    set area [lindex $temp 2]

     

    foreach comp_id [hm_entitylist comps id] {} can be used to loop through all comp ids. 

     

    At last a tcl list lst_vols can be writen to a .csv file: 

    set data [join $lst_vols "\n"]
    set tempfile [open $filepath w+]
    puts $tempfile $data
    close $tempfile &nbsp; &nbsp;
     
    Enjoy your HM scripting!