{"id":6260,"date":"2024-11-26T10:39:19","date_gmt":"2024-11-26T18:39:19","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=6260"},"modified":"2024-11-26T10:39:19","modified_gmt":"2024-11-26T18:39:19","slug":"452-save-selected-nodes-coordinates-to-csv-file-in-tcl-for-hypermesh","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2024\/11\/452-save-selected-nodes-coordinates-to-csv-file-in-tcl-for-hypermesh\/","title":{"rendered":"#452 Save selected nodes coordinates to*.csv file in tcl for HyperMesh"},"content":{"rendered":"<pre class=\"lang:python decode:true \">set script_path [ file dirname [ file normalize [ info script ] ] ]\nputs $script_path\nset output_file [file join $script_path \"nodes.csv\"]\nset file_id [open $output_file \"w\"]\nputs $file_id \"node_id,x,y,z\"\n*clearmark nodes 1\n*createmarkpanel nodes 1 \"Select Nodes\"\nset selected_nodes [hm_getmark nodes 1]\nif {[llength $selected_nodes] == 0} {\n    puts \"Nodes are not selected\"\n    close $file_id\n    return\n}\nforeach node_id $selected_nodes {\n    set x [hm_getvalue node id=$node_id dataname=x]\n    set y [hm_getvalue node id=$node_id dataname=y]\n    set z [hm_getvalue node id=$node_id dataname=z]\n    puts $file_id \"$node_id,$x,$y,$z\"\n}\nclose $file_id\n*clearmark nodes 1<\/pre>\n<p>Output:<\/p>\n<pre class=\"lang:python decode:true \">node_id,x,y,z\n1,-1.056,0.642667,0\n2,-0.778667,-0.322667,0\n3,-0.330667,0.0906667,0\n4,-1.512,0.122667,0\n5,0.696,0.00266667,0\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>set script_path [ file dirname [ file normalize [ info script ] ] ] puts $script_path set output_file [file join $script_path &#8220;nodes.csv&#8221;] set file_id [open $output_file &#8220;w&#8221;] puts $file_id &#8220;node_id,x,y,z&#8221; *clearmark nodes 1 *createmarkpanel nodes 1 &#8220;Select Nodes&#8221; set selected_nodes [hm_getmark nodes 1] if {[llength $selected_nodes] == 0} { puts &#8220;Nodes are not selected&#8221; close [&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":[23,43],"class_list":["post-6260","post","type-post","status-publish","format-standard","hentry","category-hypermesh","category-tcl","tag-hypermesh","tag-tcl"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-1CY","jetpack_likes_enabled":true,"jetpack-related-posts":[{"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":6260,"position":0},"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":1733,"url":"https:\/\/gantovnik.com\/bio-tips\/2022\/12\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2-2-4-2\/","url_meta":{"origin":6260,"position":1},"title":"#328 Add labels with node coordinates using HyperMesh Tcl","author":"gantovnik","date":"2022-12-14","format":false,"excerpt":"nodes.txt create_nodes.tcl","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\/2022\/12\/ex328.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/12\/ex328.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/12\/ex328.png?resize=525%2C300&ssl=1 1.5x"},"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":6260,"position":2},"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 Output file: ex403.txt","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":527,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/05\/tcl-command-that-retrieves-the-x-component-of-a-force-of-id-12-defined-in-the-global-system\/","url_meta":{"origin":6260,"position":3},"title":"Tcl commands","author":"gantovnik","date":"2020-05-06","format":false,"excerpt":"Tcl command that retrieves the x component of a force of ID 12 defined in the global system: To retrieve the node that load 12 is applied to: To retrieve the y coordinate of the node that load 12 is applied to: To retrieve the load collector name that contains\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":525,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/05\/tcl-script-that-prompts-the-user-to-select-nodes-and-displays-their-x-y-and-z-coordinates\/","url_meta":{"origin":6260,"position":4},"title":"Tcl script that prompts the user to select nodes and displays their x, y and z coordinates","author":"gantovnik","date":"2020-05-06","format":false,"excerpt":"Tcl script that prompts the user to select nodes and displays their x, y and z coordinates:","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"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":6260,"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: To get closest line from the set with IDs 13 14 15:\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\/6260","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=6260"}],"version-history":[{"count":1,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/6260\/revisions"}],"predecessor-version":[{"id":6267,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/6260\/revisions\/6267"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=6260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=6260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=6260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}