Exporting multiple data components to the same output file via tcl

JBrai_21100
JBrai_21100 New Altair Community Member
edited July 2023 in Community Q&A

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.

Tagged:

Answers