TCL ClosestNode and CSV Help

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hi All,

 

I am trying to extract nodes from a user selected component into a CSV. I am very new to TCL so I have been struggling with basically the whole process!

The way I would like this to work:

  • User runs the script and is prompted to select the component they want
  • Script:
    • Isolates the component
    • Displays all nodes on the component
    • Exports the nodes ID and coordinates into a CSV

 

So far my code looks like this:

 

puts 'Please select components'
*createmarkpanel components 1
*isolateentitybymark 1
*createmark nodes 1 'displayed'
hm_createmark elems 1 advanced displayed
set id [hm_getclosestnode 0 0 0 1]

 

My problem now is that I do not think the closest node code is working correctly, and I am unsure how I would export the closest node(s) into a CSV. (Eventually I hope to ask the user for several locations, and hence I will be exporting several node locations into the CSV).

 

Any advice would be greatly appreciated!

Tagged:

Answers

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited July 2019

    Hi BurntPixel,

     

    Easier way is to get the component ID and get all the nodes directly from the component:

     

     set lst_nodes [list]; puts 'Please select components' *createmarkpanel components 1 if {[hm_marklength comps 1]} {     set n_compID [hm_getmark comps 1]     *createmark nodes 1 'by comp id' $n_compID     if {[hm_marklength nodes 1]} {         set lst_nodes [hm_getmark nodes 1];     } }  if {[llength $lst_nodes]} {     foreach n_nodeID $lst_nodes {         set lst_coord [join [hm_nodevalue $n_nodeID]];         # file operation to write nodeID and lst_coord should come below this.      } }

    nodes will be saved in a tcl list lst_nodes.

     

     

    Regards,

    Livil