{"id":2017,"date":"2024-01-07T02:55:37","date_gmt":"2024-01-07T10:55:37","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=2017"},"modified":"2024-01-07T04:45:53","modified_gmt":"2024-01-07T12:45:53","slug":"402-find-edge-nodes-of-mesh-and-create-node-sets-for-each-edge-using-tcl-script-in-hypermesh","status":"publish","type":"post","link":"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\/","title":{"rendered":"#402 Find edge nodes of mesh and create node sets for each edge loop using tcl script in HyperMesh"},"content":{"rendered":"<p>Assume we have this model:<br \/>\n<a href=\"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\/ex402_1\/\" rel=\"attachment wp-att-2019\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_1.png?resize=580%2C452&#038;ssl=1\" alt=\"\" width=\"580\" height=\"452\" class=\"alignnone size-full wp-image-2019\" srcset=\"https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_1.png 580w, https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_1-480x374.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 580px, 100vw\" \/><\/a><\/p>\n<p>The script will find all edges and create set of nodes for each edge:<br \/>\n<a href=\"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\/ex402_2\/\" rel=\"attachment wp-att-2020\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_2.png?resize=211%2C148&#038;ssl=1\" alt=\"\" width=\"211\" height=\"148\" class=\"alignnone size-full wp-image-2020\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_2.png?w=211&amp;ssl=1 211w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_2.png?resize=150%2C105&amp;ssl=1 150w\" sizes=\"(max-width: 211px) 100vw, 211px\" \/><\/a><\/p>\n<p><a href=\"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\/ex402_3\/\" rel=\"attachment wp-att-2021\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_3.png?resize=606%2C475&#038;ssl=1\" alt=\"\" width=\"606\" height=\"475\" class=\"alignnone size-full wp-image-2021\" srcset=\"https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_3.png 606w, https:\/\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/01\/ex402_3-480x376.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 606px, 100vw\" \/><\/a><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n*clearmark comps 1\r\n*clearmark elems 1\r\n*createmark elems 1 &quot;by comps&quot; 1\r\n# hm_getedgeloops = Returns surface and element entities of specific connection types.\r\n# looptype=2 get all closed free (Bit1) edge loops for the displayed elements.\r\n# The return is a &quot;list of loops&quot;. Each loop is an ordered list of either surface edge or\r\n# element node IDs that define each loop. The first value in each loop list is the loop type.\r\n# The remaining values are the ordered node\/surface edge IDs defining the loop. If the loop\r\n# is closed, the first and last ID are the same.\r\nset loops &#x5B;hm_getedgeloops elems markid=1 looptype=2]\r\nset n_loops &#x5B;llength $loops]\r\nputs &quot;loops:  $loops&quot;\r\nputs &quot;n_loops:  $n_loops&quot;\r\nset i 1\r\nforeach loop $loops {\r\n    puts $loop\r\n    # delete first item in the list (loop type)\r\n    set current &#x5B;lreplace $loop 0 0]\r\n    # delete last item in the list (the first and last IDs are the same)\r\n    set current &#x5B;lreplace $current end end]\r\n    # create sets\r\n    *clearmark sets 1\r\n    *createentity sets cardimage=SET_GRID includeid=0 name=&quot;set_$i&quot;\r\n    *createmark sets 1 -1\r\n    set setID &#x5B;hm_getmark sets 1]\r\n    *setvalue sets id=$setID ids={nodes $current}\r\n    set i &#x5B;expr $i+1]\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Assume we have this model: The script will find all edges and create set of nodes for each edge: *clearmark comps 1 *clearmark elems 1 *createmark elems 1 &quot;by comps&quot; 1 # hm_getedgeloops = Returns surface and element entities of specific connection types. # looptype=2 get all closed free (Bit1) edge loops for the displayed [&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-2017","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-wx","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":771,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/130-use-a-panel-to-add-entities-to-a-mark-in-tcl-in-hypermesh\/","url_meta":{"origin":2017,"position":0},"title":"#130 Use a panel to add entities to a mark in tcl in HyperMesh","author":"gantovnik","date":"2020-11-06","format":false,"excerpt":"#130 Use a panel to add entities to a mark in tcl in HyperMesh To create a mark of elements in a panel: *createmarkpanel elems 1 \"Please select the elements\" hm_getmark elems 1 To create a mark of elements in a panel using 2D faces as the default selection mode:\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":8057,"url":"https:\/\/gantovnik.com\/bio-tips\/2025\/02\/458-hypermesh-tcl-script-to-save-selected-node-ids-and-coordinates-to-a-csv-file\/","url_meta":{"origin":2017,"position":1},"title":"#458 HyperMesh tcl script to save selected node IDs and coordinates to a csv file","author":"gantovnik","date":"2025-02-20","format":false,"excerpt":"In this example, we create n=40 random nodes, select several of them, and save their node IDs and coordinates in a csv file. proc RandomReal {min max} { return [expr (rand()*($max-$min)+$min)] } set x_min 0.0 set x_max 20.0 set y_min 0.0 set y_max 10.0 set n 40 for {set i\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\/2025\/02\/2025-02-20_005944.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":2219,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/06\/431-hypermesh-python-script-to-create-nodes-using-coordinates-from-csv-file\/","url_meta":{"origin":2017,"position":2},"title":"#431 HyperMesh python script to create nodes using coordinates from csv file","author":"gantovnik","date":"2024-06-24","format":false,"excerpt":"Finally, I read how to write a script for HyperMesh in python. In this example, the script reads the coordinates of points from a cvs file. [code language=\"python\"] import os import hm import hm.entities as e from hwx import gui import csv model=hm.Model() os.chdir(r\"D:\\projects\\wordpress\\ex431\") with open('ex431_coordinates.csv', mode ='r') as file:\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\/ex431.png?resize=350%2C200&ssl=1","width":350,"height":200},"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":2017,"position":3},"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":6260,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/11\/452-save-selected-nodes-coordinates-to-csv-file-in-tcl-for-hypermesh\/","url_meta":{"origin":2017,"position":4},"title":"#452 Save selected nodes coordinates to*.csv file in tcl for HyperMesh","author":"gantovnik","date":"2024-11-26","format":false,"excerpt":"set script_path [ file dirname [ file normalize [ info script ] ] ] puts $script_path set output_file [file join $script_path \"nodes.csv\"] set file_id [open $output_file \"w\"] puts $file_id \"node_id,x,y,z\" *clearmark nodes 1 *createmarkpanel nodes 1 \"Select Nodes\" set selected_nodes [hm_getmark nodes 1] if {[llength $selected_nodes] == 0} { puts\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":773,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/131-use-a-panel-to-create-an-ordered-list-of-entities-for-use-in-a-subsequent-command-in-tcl-in-hypermesh\/","url_meta":{"origin":2017,"position":5},"title":"#131 Use a panel to create an ordered list of entities for use in a subsequent command in tcl in HyperMesh","author":"gantovnik","date":"2020-11-06","format":false,"excerpt":"#131 Use a panel to create an ordered list of entities for use in a subsequent command in tcl in HyperMesh To create a line from a user specified list of nodes: [code language=\"python\"] *createlistpanel nodes 1 \"Select nodes for the line:\" set node_list [ hm_getlist nodes 1 ]; if\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\/2017","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=2017"}],"version-history":[{"count":3,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/2017\/revisions"}],"predecessor-version":[{"id":2025,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/2017\/revisions\/2025"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=2017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=2017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=2017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}