Dear users,
I am new new to CADINP and would like to understand how to save data to an external text file via a custom user task in the SSD task tree.
In one of the Teddy examples (csm23_Cable_stay_optimisation_2.dat) there is sucha a piece of code which does what I would like to achieve:
Code:
!#!KAPITEL Print cable forces in special table
+prog template -e urs:3
head print cable forces
page line 9999
let#no(99) 0 $ define array #no(0:99)
let#no(0) 10
let#no(1) 2101 $ cable numbers (print max. 10)
let#no(2) 2202
let#no(3) 4101
let#no(4) 4202
let#no(5) 6101
let#no(6) 6202
let#pp(99) 0 $ define array #pp(0:99)
let#printhead 1
let#rtex ' ' $ init loadcase title
let#CDB_IER 0
let#lc 4000
loop 999
let#lc #lc+1
@key LC_CTRL #lc
if #CDB_IER<2 $ if loadcase available:
let#rtex LIT(@rtex) $ read loadcase title
let#cdb_ier 0
@key CABL_RES #lc
if #CDB_IER<2 $ if cables available:
loop#i 99
let#pp(#i) 0 $ initialize cable forces with 0
endloop
loop
let#nr @(NR) $ read cable number
if #cdb_ier<2 $ if next cable successful read:
$ is this cable of interest? : look in #no table:
loop#noi #no(0)
if abs(#nr-#no(#noi+1))<0.1
let#pp(#noi+1) @(N)
endif
endloop
endif
endloop #cdb_ier<2 $ end - if all cables read -> end this loop
if #printhead>0
txe stage cable results [kN]
txe number | #(#no(1),7.0)| #(#no(2),7.0)| #(#no(3),7.0)| #(#no(4),7.0)| #(#no(5),7.0)| #(#no(6),7.0)| #(#no(7),7.0)| #(#no(8),7.0)| #(#no(9),7.0)| #(#no(10),7.0)| stage title
txe -----------------------------------------------------------------------------------------------------------------------------
let#printhead 0
endif
let#cs #lc-4000
txe #(cs,6.0) | #(#pp(1),7.1)| #(#pp(2),7.1)| #(#pp(3),7.1)| #(#pp(4),7.1)| #(#pp(5),7.1)| #(#pp(6),7.1)| #(#pp(7),7.1)| #(#pp(8),7.1)| #(#pp(9),7.1)| #(#pp(10),7.1)| #rtex $ rtex(0)#rtex(1)#rtex(2)#rtex(3)#rtex(4)#rtex(5
endif
endif
endloop
end
end
+sys del cable_forces.txt
$ ^ because some computer ask before copying (if file already exists)
+sys copy $(name).lst cable_forces.txt
I manage to acces the data I am interested in and it appears in the plb file but I do not know how to save it to text files in the project directory as in the example above.