Exporting multiple data components to the same output file via tcl
I have a .h3d-stress result file and want to export the stress tensor in XYZ-coordinates for each element, i.e. the XX-, YY-, ZZ-, XY-, YZ- and ZX-data components of the stress data type. Exporting the element stresses via a TensorCtrlHandle won't work, as these are given in the local main axis system for each element. I can pass a single component to a query like so:
set inPath "input_s1.h3d"
set outPath "output.txt"
hwi OpenStack
hwi GetSessionHandle session
session GetProjectHandle project
project GetPageHandle page 1
page GetWindowHandle win 1
win SetClientType animation
win GetClientHandle anim
set id [anim AddModel $inPath]
anim GetModelHandle myModel $id
myModel SetResult $inPath
myModel GetResultCtrlHandle myResult
set current [myResult GetCurrentSubcase]
myResult SetCurrentSimulation [expr [myResult GetNumberOfSimulations $current]-1]
set data_types [myResult GetDataTypeList $current]
myResult GetContourCtrlHandle myContour
myContour SetDataType [lindex $data_types 2]
myContour SetDataComponent == XX
myContour SetEnableState true
myModel GetQueryCtrlHandle myQuery
set set_id [myModel AddSelectionSet element]
myModel GetSelectionSetHandle elem_set $set_id
elem_set Add all
myQuery SetSelectionSet $set_id
myQuery SetQuery "element.id contour.value"
myQuery WriteData $outPath
session ReleaseHandle
project ReleaseHandle
page ReleaseHandle
win ReleaseHandle
anim ReleaseHandle
myModel ReleaseHandle
myQuery ReleaseHandle
myResult ReleaseHandle
myContour ReleaseHandle
elemSet ReleaseHandle
hwi CloseStack
But I'd like all six components to exist side by side in the same result file. I assume I have to somehow loop over the data components and pass them to a single query, but I'm not sure how the tcl-Syntax would look for that to work.
Answers
-
Hello JBrai,
as a starter, I would recommend to simplify your tcl script with the use of hwc. We have recently authored a script which explains what are the benefits of hwc compared to native tcl commands:
hwc should allow you to load your model and plot the stress tensor (not the stres contours one by one) in a quicker way.
Then, once you have plotted your tensor, replace
myQuery SetQuery "element.id contour.value"
by
myQuery SetQuery "element.id tensor.value"
Does that help?
Best Regards,
Michael
0