Create a TCL Routine for Update a Column table with node of set
Hello
I am writing a tcl script to create a table with the ID node of set:
*createstringarray 1 int
*tablecreate "NODE" 1 1 1 1
set table_id [hm_getvalue tables name=NODE dataname=id]
*createmark nodes 1 "by set" 100
set nodes_list [hm_gettablecolumndata $table_id 1]
But is not working.
Can you help me ?
Thank you in advance
Answers
-
What client are you using? What is it you are trying to accomplish by putting these node ids in a table? Not sure this is even possible but the hm_gettablecolumndata (which is replaced by hm_getvalue now) is just querying the column data not setting it and createmark is just putting those nodes on the temporary mark not doing anything with them.
You would probably want to use *setvalue but in the OptiStuct profile I don't see a way to add a list of nodes to a table.
Again not sure what you are trying to do but you may want to look into the matrix browser too.
0 -
I work in NASTRAN MSC profile And I wont write a code tlc just for populate a table automatically and after export .0
-
*createstringarray 1 int *tablecreate "pippo" 3 1 1 0 0 *createmark nodes 1 "by set" 160 set nodes_list [hm_getmark nodes 1] *createstringarray 1 $nodes_list *tableaddcolumn "pippo" "nodes" "nodes" 1 1 A new version… but not work … Sincerelly I wont understand if is it possible to do it! I'm not an expert on the subjectGiovanni Capasso said:I work in NASTRAN MSC profile And I wont write a code tlc just for populate a table automatically and after export .
0 -
Giovanni Capasso said:
*createstringarray 1 int *tablecreate "pippo" 3 1 1 0 0 *createmark nodes 1 "by set" 160 set nodes_list [hm_getmark nodes 1] *createstringarray 1 $nodes_list *tableaddcolumn "pippo" "nodes" "nodes" 1 1 A new version… but not work … Sincerelly I wont understand if is it possible to do it! I'm not an expert on the subject
If you are just trying to export the list of nodes I don't think I would bother with tables I would use matrix browser or something like the following:
*createmarkpanel nodes 1
puts [hm_getmark nodes 1]or replace the second line with the following if you want them on a different row.
foreach n [hm_getmark nodes 1] {puts $n}
You could write them to a text file with open, puts and close commands too.
0 -
I have created a piece of code that does some fem operations and exports elements belonging to the created Sets. now i can't create a rootine which exports nodes id belonging to a setBen Buchanan said:If you are just trying to export the list of nodes I don't think I would bother with tables I would use matrix browser or something like the following:
*createmarkpanel nodes 1
puts [hm_getmark nodes 1]or replace the second line with the following if you want them on a different row.
foreach n [hm_getmark nodes 1] {puts $n}
You could write them to a text file with open, puts and close commands too.
0 -
Giovanni Capasso said:
I have created a piece of code that does some fem operations and exports elements belonging to the created Sets. now i can't create a rootine which exports nodes id belonging to a set
Should work similarly. How are you exporting the elements?
0 -
Yes ! I use Set table id [hm_gettali e tablet name= Xxx dataname=id] Createmark elems 1 $table_id *findattacheddelementfaces 1 $table_id Set elemlist [hm_gettablecolumndata $table_id] But with node is not possible ..Ben Buchanan said:Should work similarly. How are you exporting the elements?
0 -
Hm_getvalue escuse meGiovanni Capasso said:Yes ! I use Set table id [hm_gettali e tablet name= Xxx dataname=id] Createmark elems 1 $table_id *findattacheddelementfaces 1 $table_id Set elemlist [hm_gettablecolumndata $table_id] But with node is not possible ..
0 -
Export table —-> csv comma delimitedGiovanni Capasso said:Hm_getvalue escuse me
0 -
Giovanni Capasso said:
Export table —-> csv comma delimited
What command are you using to export?
Does the csv look like this:
123,456,789
or this:
123
456
789
0 -
Tableexport 123 456 789Ben Buchanan said:What command are you using to export?
Does the csv look like this:
123,456,789
or this:
123
456
789
0 -
I hope you understand now what i wont obtain . In this MomentGiovanni Capasso said:Tableexport 123 456 789
0 -
In this moment i populate only the first fow of my table *createmark nodes1 “By set” x Set node_list[hm_getmark nodes 1] *createstringarray 1 $node_list *tableaddcolumn “x” “nodes” “node” 1 1 I try to popolare All the row… But i don’t know the exact command… i belive i neeed to change stringarray… have idea ?Giovanni Capasso said:I hope you understand now what i wont obtain . In this Moment
0 -
Giovanni Capasso said:
In this moment i populate only the first fow of my table *createmark nodes1 “By set” x Set node_list[hm_getmark nodes 1] *createstringarray 1 $node_list *tableaddcolumn “x” “nodes” “node” 1 1 I try to popolare All the row… But i don’t know the exact command… i belive i neeed to change stringarray… have idea ?
If you are just trying to get the nodes in a csv file I wouldn't worry about creating a table at all. I would instead just use tcl commands to export a csv.
Something like this
*createmark nodes1 “by set” x
set fp [open $filename w]
puts $fp [join [hm_getmark nodes 1] ,]
close $fp0 -
what you are doing is excessive! you could better specify the command “puts $ fp [… ..” thank you very muchBen Buchanan said:If you are just trying to get the nodes in a csv file I wouldn't worry about creating a table at all. I would instead just use tcl commands to export a csv.
Something like this
*createmark nodes1 “by set” x
set fp [open $filename w]
puts $fp [join [hm_getmark nodes 1] ,]
close $fp0 -
Ahahaha escuse me … what I am doing is excessive! you could better specify the command “puts $ fp [… ..” thank you very muchGiovanni Capasso said:what you are doing is excessive! you could better specify the command “puts $ fp [… ..” thank you very much
0 -
is it possible to get a txt file with the data in column?Giovanni Capasso said:Ahahaha escuse me … what I am doing is excessive! you could better specify the command “puts $ fp [… ..” thank you very much
0 -
Please?Giovanni Capasso said:is it possible to get a txt file with the data in column?
0 -
Giovanni Capasso said:
Please?
Here is a help page for the puts command:
https://www.tcl.tk/man/tcl8.5/TclCmd/puts.html
The open command gets you an i\o stream. Then if you put that stream as the first argument to the puts command it writes to that file instead of to the console. The join command just joins a list with the second argument (in the previous case a comma). You can also use the join with \n which will create a new line for each item in the list.
Like this:
*createmark nodes1 “by set” x
set fp [open $filename w]
puts $fp [join [hm_getmark nodes 1] \n]
close $fp0 -
thanks for everything ! I was doing many things wrong! a thousand thanks !????Ben Buchanan said:Here is a help page for the puts command:
https://www.tcl.tk/man/tcl8.5/TclCmd/puts.html
The open command gets you an i\o stream. Then if you put that stream as the first argument to the puts command it writes to that file instead of to the console. The join command just joins a list with the second argument (in the previous case a comma). You can also use the join with \n which will create a new line for each item in the list.
Like this:
*createmark nodes1 “by set” x
set fp [open $filename w]
puts $fp [join [hm_getmark nodes 1] \n]
close $fp0