automation of query of Nodes vector values

Junhyeong Kang
Junhyeong Kang Altair Community Member
edited November 2023 in Community Q&A

hello all, im on the post processing to automate the results data. im done with automation of contour vaules of every nodes for each subcase(centrifugal force distributions in Rotor depends on RPM). and now i want to also query vector values of each node for each subcase. but i couldnt find any TCL Commend for it.

do you guys have idea for automation to query vector? thanks

here is my automation TCL commend.

hwi GetSessionHandle session
session GetProjectHandle project
project GetPageHandle page [project GetActivePage]
page GetWindowHandle window [page GetActiveWindow]
window GetClientHandle client
client GetModelHandle model [client GetActiveModel]
model GetResultCtrlHandle result
 
result GetContourCtrlHandle contour
 
contour SetDataType "Element Stresses (2D & 3D)"
contour SetDataComponent component vonMises
contour SetAverageMode advanced
contour SetLayer Max
contour SetEnableState True
contour SetResultSystem 0
contour SetDimensionEnabled solid True
contour SetDimensionEnabled shell True
contour SetEnableState True
 
 
 
client GetMeasureHandle measure 1
model GetQueryCtrlHandle myQueryName
model GetSelectionSetHandle mySetName [model AddSelectionSet  node]
mySetName Add all
 
lappend max_stress
set subcases [result GetSubcaseList "Base"]
puts "Subcaselist: $subcases"
foreach i $subcases {
result SetCurrentSubcase $i                  ;# nächsten Subcase auswählen
client Draw                                   ;# refresh View
result SetCurrentSimulation $i
myQueryName SetDataSourceProperty result datatype Stress
myQueryName SetDataSourceProperty result shelllayer Upper
myQueryName SetQuery "node.id, node.coords, contour.value"
myQueryName SetSelectionSet [mySetName GetID]
myQueryName WriteData {D:/junhyeong/Spannungsdaten/test.csv}
 
    file rename -force D:/junhyeong/Spannungsdaten/test.csv D:/junhyeong/Spannungsdaten/${i}.csv
lappend max_stress [measure GetMaximum scalar]     ;# Maximum an Liste anhängen
}
 
 
# Export der maximalen Spannungen
set responses_file [open "struct_responses.json" "w"]
set line "\[[join $max_stress ", "]\]"
puts -nonewline $responses_file $line
close $responses_file
Tagged:

Answers

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited November 2023

    I see this question a couple times in here.

    Could you provide a smaple file, of a couple slides showing what is going on?

     

    Another option would be to use Altair Compose to read the data and write a .csv from it.

  • Junhyeong Kang
    Junhyeong Kang Altair Community Member
    edited November 2023

    I see this question a couple times in here.

    Could you provide a smaple file, of a couple slides showing what is going on?

     

    Another option would be to use Altair Compose to read the data and write a .csv from it.

    here u can see what i tried to create. see # query vector value and im using 2022.1 version.
     
    hwi GetSessionHandle session
    session GetProjectHandle project
    project GetPageHandle page [project GetActivePage]
    page GetWindowHandle window [page GetActiveWindow]
    window GetClientHandle client
    client GetModelHandle model [client GetActiveModel]
    model GetResultCtrlHandle result
     
    result GetContourCtrlHandle contour
     
    contour SetDataType "Element Stresses (2D & 3D)"
    contour SetDataComponent component vonMises
    contour SetAverageMode advanced
    contour SetLayer Max
    contour SetEnableState True
    contour SetResultSystem 0
    contour SetDimensionEnabled solid True
    contour SetDimensionEnabled shell True
    contour SetEnableState True
     
    client GetMeasureHandle measure 1
    model GetQueryCtrlHandle myQueryName
    model GetSelectionSetHandle mySetName [model AddSelectionSet  node]
    mySetName Add all
     
    lappend max_stress
    set subcases [result GetSubcaseList "Base"]
    puts "Subcaselist: $subcases"
    foreach i $subcases {
    result SetCurrentSubcase $i                  ;# nächsten Subcase auswählen
    client Draw                                   ;# refresh View
    result SetCurrentSimulation $i
    myQueryName SetDataSourceProperty result datatype Stress
    myQueryName SetDataSourceProperty result shelllayer Upper
    myQueryName SetQuery "node.id, node.coords, contour.value"
    myQueryName SetSelectionSet [mySetName GetID]
    myQueryName WriteData {D:/junhyeong/Spannungsdaten/test.csv}
     
        file rename -force D:/junhyeong/Spannungsdaten/test.csv D:/junhyeong/Spannungsdaten/${i}.csv
     
    # Query Vector value
    set resultType(Displacement)
    set node [hm_getmark nodes]
     
    set vectorData ""
    foreach node $nodes{
    set vectorValue [result GetNodalVectorValue $node $resultType]
    set vectorDaTa "${vectorDaTa}${node} $vectorValue\n"
    }
    set dir "D:/junhyeong/Vektordaten"
    file mkdir $dir
    set fileName "Subcase_${i}.csv"
    set fileId [open $fileName "w"]
    puts -nonewline $fileId $vectorDaTa
    close $fileId
     
    lappend max_stress [measure GetMaximum scalar]     ;# Maximum an Liste anhängen
    }
     
     
    # Export der maximalen Spannungen
    set responses_file [open "struct_responses.json" "w"]
    set line "\[[join $max_stress ", "]\]"
    puts -nonewline $responses_file $line
    close $responses_file