*createmark comps 1 "all"
set comp_id_list [hm_getmark comps 1]
set total_surf_area 0
foreach comp_id $comp_id_list {
    *createmark surfs 1 "by comp id" $comp_id
    set surf_id_list [hm_getmark surfs 1]
    foreach surf_id $surf_id_list {
        set surf_area [hm_getareaofsurface surfs $surf_id]
		puts "The area of surface ${surf_id} is ${surf_area}"
        set total_surf_area [expr {$total_surf_area+$surf_area}]
    }
}

puts "The total area is ${total_surf_area}"
tk_messageBox -message "The total area is ${total_surf_area}"

Output:

The area of surface 1 is 64.0
The area of surface 2 is 64.0
The area of surface 3 is 64.0
The area of surface 4 is 64.0
The total area is 256.0

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading