Advanced Query via tcl script.

Daniel_20616
Daniel_20616 Altair Community Member
edited June 20 in Community Q&A

Hello.

I have a model with already applied contour. At the moment I manually have to advanced query and perform my input in the popup window. This will then be exported into a csv file. Since I have to perform this process over and over again, I would like to automate it via a tcl script. Applying the contour is already done via hwc commands in the tcl script. My problem is now how I can write my user selection from the popup window in the tcl file and then export the results to a csv file.

Thanks in advance.

image

Answers

  • Adriano_Koga
    Adriano_Koga
    Altair Employee
    edited June 11

    you will need to use pure HV TCL APIs from this class:

    https://2021.help.altair.com/2021.1/hwdesktop/hwd/topics/chapter_heads/poiadvancedquery_class_r.htm

     

    It will allow you to access the advanced query functions, such as WriteData, as you're looking for.

    Assuming that you have some familiarity with programming scripts in HV, it will do the job.

     

    There are a few lines of example here:

    https://2021.help.altair.com/2021.1/hwdesktop/hwd/topics/reference/tcl/poiadvancedquery_writedata.htm

  • Daniel_20616
    Daniel_20616 Altair Community Member
    edited June 11

    you will need to use pure HV TCL APIs from this class:

    https://2021.help.altair.com/2021.1/hwdesktop/hwd/topics/chapter_heads/poiadvancedquery_class_r.htm

     

    It will allow you to access the advanced query functions, such as WriteData, as you're looking for.

    Assuming that you have some familiarity with programming scripts in HV, it will do the job.

     

    There are a few lines of example here:

    https://2021.help.altair.com/2021.1/hwdesktop/hwd/topics/reference/tcl/poiadvancedquery_writedata.htm

    Thank you for your reply.

    I already tried this and executed the example lines with writedata. It indeed returns a csv file, but I don't think this is from advanced query. I am quite new to tcl scripting so maybe I am missing something but I don't know how to assign the input, which is made in the "Advanced Query" popup window to the tcl script. E.g. in the popup window, I want to get the Top 10 nodes for every loadcase. With the example lines I only get the Top 10 nodes overall.

    This is the Code I used:

    hwi OpenStack
    hwi GetActiveClientHandle client
    set ruleID [client AddQueryRule extreme]
    client GetQueryRuleHandle rule_handle $ruleID
    rule_handle SetExtreme "TopN 10"
    set advQueryID [client AddAdvancedQuery]
    client GetAdvancedQueryHandle advancedQuery_handle $advQueryID
    advancedQuery_handle AddSimulations "all" "all"
    advancedQuery_handle SetQuery "subcase.label simulation.label entity.id component.id entity.value"
    advancedQuery_handle SetQueryLogic "[rule_handle GetID]" 
    advancedQuery_handle WriteData "advQueryResult_1.csv"
    hwi CloseStack

    It seems for me that the only input I can specify is the TopN 10 with SetExtreme (but this is also not working properly). I do not know how to specify the other inputs.

  • Daniel_20616
    Daniel_20616 Altair Community Member
    edited June 20

    Hello everybody.

    Since I did not make any further progress on performing advanced query via tcl, I want to try a different method. In the advanced query popup window there is a button for loading a config file. My idea is now to write a config file with my input selection and load this via tcl. Does anyone know if this is possible and how I can call the config file in the tcl script?

    Here is a sample config file:

    https://2022.help.altair.com/2022/hwdesktop/hwx/topics/panels/advanced_query_sample_config_file_r.htm

    Also I do not quite get, how I can alter the sample file to fit to my selection from the screenshot in the first question.

    Thanks in advance.