Tcl script for summation of loads and moments at specific point

Vladimir Gantovnik_21974
Vladimir Gantovnik_21974 Altair Community Member
edited April 2022 in Community Q&A

Hi Engineers! I have a question: how do you write a script that will give values of summation of forces and moments at the selected point. For example, I have a surface (wing) loaded by pressure (PLOAD4), and I want to know the resulting shear forces, bending moment, and torsion moment at the root of the wing.  In HyperMesh GUI, I see Bcs/Check/Loads Summation, but I want to have a tcl script.

Thank you!

 

Best Answer

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited April 2022 Answer ✓

    Hi, Adriano! Thank you, but 1) if I need a tcl script, when I need a tcl script. The function will be part of a larger tcl code. Is it possible to use that FBD tool you suggested in tcl - probably not? 2) "some TCL scripting on your own, taking a look at some tutorials, etc." Common, I am a good tcl hypermesh programmer :) So, unfortunately, both of your suggestions are useless :) 

    Ok. So the question was, do we have a tcl function in API that will make a summation of PLOAD4 pressure loads and moments at the given node? 

    If there is no such function, how can I get the value of the PLOAD4 card at the given element? We know how to get the area of the given area, but what about the applied pressure?

    #get area of element 23 *createmark elements 1 23 set masscalc [hm_getmass elems 1] #calculate area of element set area [lindex $masscalc 2] puts $area

    Thank you!

    I'd say FBD tools would be your solution here, but i don't know if it is possible to call these in batch...

     

    Now, concerning your specific questions:

    you could use hm_getvalue to retrieve these values mcuh easily, and for many items at once.

     

    something like:

     

    hm_getvalue elems user_ids=${elems_list} dataname=area

     

    hm_getvalue loads user_ids=${loads_list} dataname=facearea

    hm_getvalue loads user_ids=${loads_list} dataname=magnitude

     

    image

Answers

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited April 2022

    i understand that you want to create your on script, and for that i'm not sure what you need for help, besides going through some TCL scripting on your own, taking a look at some tutorials, and so on.

     

    But, just as a FYI, there is already a tool in both HM and HV, called FBD (Free Body Diagram), that does what you need. maybe it would be nice to take a look on these, too.

  • Vladimir Gantovnik_21974
    Vladimir Gantovnik_21974 Altair Community Member
    edited April 2022

    i understand that you want to create your on script, and for that i'm not sure what you need for help, besides going through some TCL scripting on your own, taking a look at some tutorials, and so on.

     

    But, just as a FYI, there is already a tool in both HM and HV, called FBD (Free Body Diagram), that does what you need. maybe it would be nice to take a look on these, too.

    Hi, Adriano! Thank you, but 1) if I need a tcl script, when I need a tcl script. The function will be part of a larger tcl code. Is it possible to use that FBD tool you suggested in tcl - probably not? 2) "some TCL scripting on your own, taking a look at some tutorials, etc." Common, I am a good tcl hypermesh programmer :) So, unfortunately, both of your suggestions are useless :) 

    Ok. So the question was, do we have a tcl function in API that will make a summation of PLOAD4 pressure loads and moments at the given node? 

    If there is no such function, how can I get the value of the PLOAD4 card at the given element? We know how to get the area of the given area, but what about the applied pressure?

    #get area of element 23 *createmark elements 1 23 set masscalc [hm_getmass elems 1] #calculate area of element set area [lindex $masscalc 2] puts $area

    Thank you!

  • Adriano A. Koga
    Adriano A. Koga
    Altair Employee
    edited April 2022 Answer ✓

    Hi, Adriano! Thank you, but 1) if I need a tcl script, when I need a tcl script. The function will be part of a larger tcl code. Is it possible to use that FBD tool you suggested in tcl - probably not? 2) "some TCL scripting on your own, taking a look at some tutorials, etc." Common, I am a good tcl hypermesh programmer :) So, unfortunately, both of your suggestions are useless :) 

    Ok. So the question was, do we have a tcl function in API that will make a summation of PLOAD4 pressure loads and moments at the given node? 

    If there is no such function, how can I get the value of the PLOAD4 card at the given element? We know how to get the area of the given area, but what about the applied pressure?

    #get area of element 23 *createmark elements 1 23 set masscalc [hm_getmass elems 1] #calculate area of element set area [lindex $masscalc 2] puts $area

    Thank you!

    I'd say FBD tools would be your solution here, but i don't know if it is possible to call these in batch...

     

    Now, concerning your specific questions:

    you could use hm_getvalue to retrieve these values mcuh easily, and for many items at once.

     

    something like:

     

    hm_getvalue elems user_ids=${elems_list} dataname=area

     

    hm_getvalue loads user_ids=${loads_list} dataname=facearea

    hm_getvalue loads user_ids=${loads_list} dataname=magnitude

     

    image

  • Vladimir Gantovnik_21974
    Vladimir Gantovnik_21974 Altair Community Member
    edited April 2022

    Thank you, Adriano! I forgot about data names. 

    These commands work very well.

    set area [hm_getvalue elems id=$eid dataname=area] set magnitude [hm_getvalue loads id=$eid dataname=magnitude]  

    I even extracted the vector components of normals for each element:

    set Nx [hm_getvalue elems id=$eid dataname=normalx] set Ny [hm_getvalue elems id=$eid dataname=normaly] set Nz [hm_getvalue elems id=$eid dataname=normalz]

    May, be you will help me with another question too. I have a model in the file model.hm and tcl script summation.tcl This tcl file slightly modifies applied forces (pressure) and calculates the summation of loads and moments at the given point. I can run this tcl file from the HyperMesh menu, and it works.

    But I want to do it in batch mode. I tried to run this bat file

    "[path]/hmbatch.exe" -tcl C:/project2/summation.tcl cmd

    But it does not work. It says 

    Error:  The file being opened for reading does not exist. End of command file - terminating. HM exiting with code 0

    How to apply my script to model.hm in batch mode? Should I open model.hm inside summation.tcl?

    Thank you!