Measuring Curve Lengths in HyperMesh with Tcl
Need the length of a curved line in HyperMesh — the actual arc length, not the straight-line distance between its endpoints? There’s a built-in Tcl query command for exactly that: hm_linelength.
The command
|
1 2 |
hm_linelength $line_id |
It returns the true length along the curve, correctly handling curvature — not a chord approximation. Pass it several IDs at once and it returns their summed length (each ID only counted once, even if repeated).
Measuring every line in the model
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
proc measure_all_line_lengths {{csv_path ""}} { *createmark lines 1 "all" set line_ids [hm_getmark lines 1] *clearmark lines 1 set total 0.0 set rows {} foreach lid $line_ids { set len [hm_linelength $lid] puts "Line $lid : length = $len" lappend rows "$lid,$len" set total [expr {$total + $len}] } puts "----" puts "[llength $line_ids] lines, total length = $total" if {$csv_path != ""} { set fh [open $csv_path w] puts $fh "line_id,length" foreach r $rows { puts $fh $r } close $fh } return $total } measure_all_line_lengths "line_lengths.csv" |
*createmark lines 1 "all" grabs every line in the database, hm_getmark pulls the IDs into a Tcl list, and the loop reports each one’s length plus a running total — optionally dumped to a CSV for a spreadsheet.
One gotcha
Some HyperMesh versions expose hm_createmark / hm_clearmark as convenience wrappers; others don’t, and you’ll hit invalid command name "hm_clearmark". The asterisk-prefixed originals — *createmark and *clearmark, used above — are the safer, universally-available choice.
Measuring a specific selection instead
Swap "all" for an interactive pick if you only want a handful of curves:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
proc measure_selected_line_lengths {} { *createmark lines 1 *createmarkpanel lines 1 "Select curves to measure" set line_ids [hm_getmark lines 1] *clearmark lines 1 set total 0.0 foreach lid $line_ids { set len [hm_linelength $lid] puts "Line $lid : length = $len" set total [expr {$total + $len}] } puts "Total selected length: $total" return $total } |
*createmarkpanel opens the standard entity-selection prompt in the modeling window and waits for you to pick curves before continuing.
Last Updated on 2026-07-30 by gantovnik
Recent Comments