Run Tcl script to get model information from Hyperview?

Jyge
Jyge Altair Community Member
edited July 2023 in Community Q&A

I have a .h3d Result file from Optistruct run. I would like to extract model information from it and I think it is not possible directly with OML.

For example, I have some element set definitions in the calculation model and I would like to get those element IDs belonging to a certain set.

Now I have already a tcl file which does the job and puts the IDs into a listvariable ContentList. Now I am trying to call that tcl script from Compose

with:

setid = 100; [status,errormessage]=exporttotcl (setid,'setid') [status,errormessage]=evaltclfile('D:/get_sets.tcl') [omlvariablename,status,errormessage]=gettclvar ('ContentList')

so I want to pass the set id 100, which the element set I am interested in, into Tcl, run the script and get the tcl List containing the IDs back to OML.

I simply get:

errormessage = invalid command name "hwi"

apparently I am running tcl, but it is not the one connecting to the Hyperworks/Hyperview? If I use a simple code snippet in standard Tcl:

puts $setid set ContentList {20 13 40} lappend ContentList $setid

I can see that the communication works. Tcl script will see the variable setid and OML will get the ContentList in return but not if I am trying to do something with API specific commands. 

Furthermore, I think that in the end I want to execute the Hyperview in Batch-mode without GUI, so I probably need to execute the system command for batch-execution and not evaltclfile. I am wondering if, in that case, I can even pass the variable data back and forth to the tcl. Does anyone has experience doing something like this? 

Answers

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023

    Hi Jyrki,

    As you've already found out, hwi and hwc APIs are available only in HyperWorks, not Compose. However, there's some very simple workarounds.

    You can always create tcl files through a Compose script using fopen, fprintf and fclose commands.

    Tha Altair Integration library contains commands setaltairfolder and callaltairbatch. Calling HyperView and running a tcl script with this command would be something like:

    callaltairbatch('hv', '-tcl MyHyperViewScript.tcl')

    For retrieving data extracted by your tcl script back into OML, I'm thinking you could write a file with the tcl script and then read it in Compose. In this way, you can leverage both the API and Compose's OML capabilities.

    Hope these tips work!

    Rafael

  • Jyrki  Majamaki
    Jyrki Majamaki Altair Community Member
    edited July 2023

    Yes, thank you. The only thing is that I need to put, at least, -b option into that to go into background, otherwise it will pop up the whole HyperView. Using a temporary dumpfile is not a problem. Unfortunately, the process of gearing up the Hyperview (even in batch mode) and reading in the model take some time here.