{"id":1950,"date":"2023-08-15T04:14:31","date_gmt":"2023-08-15T11:14:31","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1950"},"modified":"2023-08-15T04:14:31","modified_gmt":"2023-08-15T11:14:31","slug":"388-hypermesh-tcl-script-to-calculate-total-area-of-all-components","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/388-hypermesh-tcl-script-to-calculate-total-area-of-all-components\/","title":{"rendered":"#388 HyperMesh tcl script to calculate total area of all components"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n*createmark comps 1 &quot;all&quot;\r\nset comp_id_list &#x5B;hm_getmark comps 1]\r\nset total_surf_area 0\r\nforeach comp_id $comp_id_list {\r\n    *createmark surfs 1 &quot;by comp id&quot; $comp_id\r\n    set surf_id_list &#x5B;hm_getmark surfs 1]\r\n    foreach surf_id $surf_id_list {\r\n        set surf_area &#x5B;hm_getareaofsurface surfs $surf_id]\r\n\t\tputs &quot;The area of surface ${surf_id} is ${surf_area}&quot;\r\n        set total_surf_area &#x5B;expr {$total_surf_area+$surf_area}]\r\n    }\r\n}\r\n\r\nputs &quot;The total area is ${total_surf_area}&quot;\r\ntk_messageBox -message &quot;The total area is ${total_surf_area}&quot;\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nThe area of surface 1 is 64.0\r\nThe area of surface 2 is 64.0\r\nThe area of surface 3 is 64.0\r\nThe area of surface 4 is 64.0\r\nThe total area is 256.0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>*createmark comps 1 &quot;all&quot; set comp_id_list &#x5B;hm_getmark comps 1] set total_surf_area 0 foreach comp_id $comp_id_list { *createmark surfs 1 &quot;by comp id&quot; $comp_id set surf_id_list &#x5B;hm_getmark surfs 1] foreach surf_id $surf_id_list { set surf_area &#x5B;hm_getareaofsurface surfs $surf_id] puts &quot;The area of surface ${surf_id} is ${surf_area}&quot; set total_surf_area &#x5B;expr {$total_surf_area+$surf_area}] } } puts &quot;The total area [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[24,27],"tags":[],"class_list":["post-1950","post","type-post","status-publish","format-standard","hentry","category-hypermesh","category-tcl"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-vs","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2017,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/402-find-edge-nodes-of-mesh-and-create-node-sets-for-each-edge-using-tcl-script-in-hypermesh\/","url_meta":{"origin":1950,"position":0},"title":"#402 Find edge nodes of mesh and create node sets for each edge loop using tcl script in HyperMesh","author":"gantovnik","date":"2024-01-07","format":false,"excerpt":"Assume we have this model: The script will find all edges and create set of nodes for each edge: [code language=\"python\"] *clearmark comps 1 *clearmark elems 1 *createmark elems 1 \"by comps\" 1 # hm_getedgeloops = Returns surface and element entities of specific connection types. # looptype=2 get all closed\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_3.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":940,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/08\/169-measures-the-shortest-distance-between-two-entity-selections-in-tcl-hypermesh\/","url_meta":{"origin":1950,"position":1},"title":"#169 Measures the shortest distance between two entity selections in HyperMesh tcl","author":"gantovnik","date":"2021-08-26","format":false,"excerpt":"#169 Measures the shortest distance between two entity selections in HyperMesh tcl To get the shortest distance between nodes 100-200 and nodes 300-400: [code language=\"python\"] *createmark nodes 1 100-200 *createmark nodes 2 300-400 hm_measureshortestdistance nodes 1 0 nodes 2 0 0 [\/code] To get the shortest distance between surface 100\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2235,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/06\/432-hypermesh-tcl-script-to-mark-and-print-all-adjacent-element-ids\/","url_meta":{"origin":1950,"position":2},"title":"#432 Hypermesh tcl script to mark and print all adjacent element IDs","author":"gantovnik","date":"2024-06-30","format":false,"excerpt":"[code language=\"python\"] *createmark elements 1 \"all\" *numbersmark elements 1 0 *clearmark elems 1 *clearmark elems 2 *createmarkpanel elems 1 \"Select elements\" set selected [hm_getmark elems 1] *setoption force_text_black=1 *setoption element_color_mode=2 *numbersmark elements 1 1 foreach ID $selected { puts \"Selected elements ID: $ID\" #select attached *createmark elems 1 $ID *findmark\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex432.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex432.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex432.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex432.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/06\/ex432.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":765,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/129-geometric-centroid-for-selected-entities-using-tcl-in-hypermesh\/","url_meta":{"origin":1950,"position":3},"title":"#129 Geometric centroid for selected entities using tcl in HyperMesh","author":"gantovnik","date":"2020-11-02","format":false,"excerpt":"#129 Geometric centroid for selected entities using tcl in HyperMesh To get the centroid of all surfaces: [code language=\"python\"] *createmark surfs 1 all hm_getcentroid surfs 1 [\/code]","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2032,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/403-get-nodes-for-all-elements-in-the-fem-model-in-hypermesh-using-tcl-script\/","url_meta":{"origin":1950,"position":4},"title":"#403 Get nodes for all elements in the FEM model in HyperMesh using tcl script","author":"gantovnik","date":"2024-01-13","format":false,"excerpt":"ex403.tcl [code language=\"python\"] set script_path [ file dirname [ file normalize [ info script ] ] ] puts $script_path cd $script_path pwd *createmark elems 1 all set elemList [ hm_getmark elements 1 ] *clearmark elements 1 set outfile [open \"ex403.txt\" w] foreach elem_id $elemList { # Get the list of\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":943,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/09\/170-gets-the-distance-of-the-given-point-from-the-nearest-line-with-ids-specified-as-arguments-in-hypermesh-tcl\/","url_meta":{"origin":1950,"position":5},"title":"#170 Gets the distance of the given point from the nearest line with IDs specified as arguments in HyperMesh tcl","author":"gantovnik","date":"2021-09-01","format":false,"excerpt":"#170 Gets the distance of the given point from the nearest line with IDs specified as arguments in HyperMesh tcl. To get closest to the point with coordinates (10, 20, 30) point on the line with ID 13: [code language=\"python\"] hm_getdistancefromnearestline [list 10 20 30] 13 [\/code] To get closest\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=1950"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1950\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}