How to export a tcl variable's value in template

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Dear all,

I am trying to recall the value of one variable which is obtained inside one of the TCL files in template file. For example, the variable name is $question, which can be obtained inside usr/11.0/hm/scripts/equation.tcl. Then in the template file .tpl I will need to output that value into a output file, how do I get that value. I tried to set question as global variable in tcl file but it seems not working. Can anyone help?

Regards,

Chong

Answers

  • tinh
    tinh Altair Community Member
    edited January 2013

    Hi, Chong

    i don't know whether template can interface to tcl but if you want to use variable in template, command *variableset and *uservariableset may be useful

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited January 2013

    Hi, Tinh

    Is there certain way that I can save some variable into Hyperworks and use template to write out the value of that variable? Just like wut we did for gemeotry.

  • tinh
    tinh Altair Community Member
    edited January 2013

    Hi, Chong

    if you want that, you can save variable name and variable value into datanames, template can access all datanames

    In this case, i think *metadata() is useful, it can store many types of datum (int, real, string, ...)

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited January 2013

    I still have some trouble write that metadata out in template file

    I have the following in my tcl file:

    *createmark solids 1 'all';

    *metadatamarkint solids 1 'microflag' 3;

    *metadatamarkint solids 1 'constflag' 4;

    -Assuming I added two integer flags onto all the solids

    How do I output those two datanames in template?

    I was trying to use metadata() but did not figure out how to only output these two datanames without those solids ids, do you know how to do it?

  • tinh
    tinh Altair Community Member
    edited January 2013

    Hi, Chong

    In order to work with template, you have to study datanames, templex commands & funtions, all are available in Reference Guide of hypermesh

    i will post a mimimal example here. You can refer many template in [installdir]\templates\feoutput

    *metadata()

    *format()

    *field(string,name,0)

    *string(' = ')

    *field(integer,data,0)

    *end()

    *output()

    Above template will output all integer metadata. And to store metadata, you don't need solids (and other) entities, just *createmark undef 1,

    then mark your data *metadatamarkint undef 1

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2013

    Hey, Tinh

    I finished that template file, thanks for your help. However when I was trying to call the same data in another tcl file, I encountered some trouble. My metadata is formed in a doublearray with 22 elements in undef type. Is there a way I can get the first element from it.

    I tried using hm_metadata findbytype undef, it returns the whole thing but after that I tried couple commands like *hm_getentityvalue and so on to get the first component, none of them recognize the entity type undef, do you have a clue on this?

    Regards,

    Chong

  • tinh
    tinh Altair Community Member
    edited February 2013

    Hi Chong

    It's ok if you use findbyname, for example

    #create metadata

    *createmark undef 1

    *createdoublearray 3 1.1 1.2 1.3

    *metadatamarkdoublearray undef 1 ThisDoubleArray 1 3

    #retrieve double array

    set ThisDoubleArrayInfo [hm_metadata findbyname ThisDoubleArray undef]

    set ThisDoubleArray [lindex $ThisDoubleArrayInfo 0 end]

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2013

    Hey, Tinh

    Thanks a lot~~That works just well. I feel that without your help, I could have not gone anywhere for my project. -) Here is another question, are there any commands that I can use to modify some of the nodal or elemental values inside the results file? Just like in Ansys, we have DESOL and DNSOL to defines or modifies solution results at a node of an element. I wish I can do this in Hyperworks too.

    Best Regards,

    Chong

  • tinh
    tinh Altair Community Member
    edited February 2013

    Your welcome! Chong,

    I am not sure whether we can modify result data in hw, hope some certain colleagues know this.

    But if you want to modify a result file (in ascii text format), you can do it by file tasks (read, modify, then write new data)

    However result files are often in binary format that we may not comprehend its structure. In this case, you should set solver to output your concern data as a text format

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2013

    Dear Tinh,

    Again thanks for the reminding. I got it done by generating a hwascii file and then change can be applied and loaded back. Do you know the tcl command to launch hyperview and load my h3d model file and hwascii result file? I wish to have this automatically when i get the result file.

    Best Regards,

    Chong

  • tinh
    tinh Altair Community Member
    edited February 2013

    Hi

    you can open hyperview by tcl call:

    exec C:/altairwin64/hm10.0/hw/bin/hw.exe -i $hw_session_file & ;

    you need make a hyperview session file, and modify 2nd and 3rd lines those point to h3d model file and hwascii result file, like below:

    { safe_quotes_on }

    { GRAPHIC_FILE_1 = '../../../lsdyna/sample/airbag_deploy.k'}

    { RESULT_FILE_1 = '../../../lsdyna/sample/d3plot'}

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2013

    Hi Tinh,

    Thanks a lot, you are always helpful to me. A small issue here, do you know how to show a result in a undeformed configuration in hyperview? After I loaded the result, the structure shape changed, is there a way I can see the results upon the undeformed shape?

    Best Regards,

    Chong

  • tinh
    tinh Altair Community Member
    edited February 2013

    your welcome

    On panel 'deformed', you set 'Value:' to '0' instead of '1', the shape will not be deformed

    You can do this before saving session file to automation your process

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2013

    Hey,

    Thanks again~~

    Regards,

    Chong

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2014

    Hi All,

     

          I am writing a script for updating the free nodes of rbe2 and rbe3. 

     

          I have 'n' no of nodes with 123 DOF. 

     

         What I have done is,

     

                   set bet_nodes [hm_getmark nodes 1]

     

                   set m1 [llength $bet_nodes]

         

                    *Createarray $m1 123             (syntax : *Createarray(no of nodes) dof )

     

                    *Createdoublearray $m1 1      (syntax : *Createdoublearray(no of nodes) dof )  

     

    Can any one help in this one.?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited February 2014

    Hi All,

     

           I have doubt in using the syntax - 'by collected Config'

     

           *createmark elements 1 'by collected config' rigidlink

           set n1 [hm_getmark elements 1]

           set l1 [llength $n1]

           puts '$n1  $l1 '

     

           If the selected element is rbe3, then $n1 and $l1 is equal to one. Am I right?

     

           But in my case, If I select rbe3 element, then it is showing ----- $n1 =   (empty space) and $l1 = 0.

     

    What is the solution for this....
  • tinh
    tinh Altair Community Member
    edited March 2014

    hi

    rbe3 config is rbe3 but not rigidlink

    and using 'by config' to mark elems