Define Load via TCL Script by external file
Dear all,
i want to create forces on nodes via tcl script. Force components are defined by external file (load.csv).
The script does not work. Can anyone see the error in the script?
autoloadgen.tcl
set fp [open 'load.csv' r];
while {![eof $fp]} {
set x [gets $fp line]
if {$x > 0} {
set line [split $line ';'];
set nodeid [lindex $line 0]
set fx [lindex $line 1]
set fy [lindex $line 2]
set fz [lindex $line 3]
set magn [lindex $line 4]
}
*createmark nodes 1 $nodeid
*loadcreateonentity_curve nodes 1 1 1 $fx $fy $fz 0 0 $magn 0 0 0 0 0
}
close $fp
load.csv
nodeid;fx;fy;fz;magn;
1553476;1000;1000;1000;1732.050808;
Best regards
kned
Answers
-
Hello,
I think there might be two adaptions needed:
1) The ',' delimiter needs to be used in the CSV file
2) The *loadcreateonentity_curve nodes 1 1 1 0 1 $listx1 $listy1 $listz1 $listmagn 0 0 0 0 0 should be
*loadcreateonentity_curve nodes 1 1 1 $listx1 $listy1 $listz1 $listmagn 0 0 0 0 0Then it will work correctly.
By the way: the error in the original script comes from the Header in the CSV file. If you remove the Header nodeid;fx;fy;fz;magn, your original script will work as well.
Jan0 -
Many thanks!
it works without header in the load file.
0