Calculate the total area of a list of components with fixed name
Answers
-
Seems like there must me a command to do this for multiple surfaces but all I found was one that does it for one surface so you would have to use expr to add them mainly after getting the area for each surface.
Help page for hm_getareaofsurface
So something like this should work for you:
set totalArea 0.0
foreach surfID $surfList {
set totalArea [expr {$totalArea + [hm_getareaofsurface surfs $surfID]}]
}
0 -
*createmarkpanel comps 1 "Please select components"
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]
set total_surf_area [expr {$total_surf_area+$surf_area}]
}
}
tk_messageBox -message "The total area is ${total_surf_area}"1 -
I used this code and it works perfectly!
Thanks a lot All for your help!
Regards,
Fabio
0