How to get user input in HYPERVIEW

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

Hello

 

I want to take some values from user so how can I take values from user

 

Like in Hypermesh we use hm_getfloat 

 

Is there any command which will serve same purpose in hyperview??

«1

Answers

  • tinh
    tinh Altair Community Member
    edited December 2016

    Hi, 

    please search for input box in tklib

    or you can write your own, by dumping tk_dialog, and add an entry on it

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2016

    Ok I will search for that

     

    But will direct tcl commands work in hyperview script?

     

    And it will be really helpful if you give any example script you have

     

    And will it pop up window or where we supposed to enter values?

  • tinh
    tinh Altair Community Member
    edited December 2016

    Hi 

    i dont know direct command

    open window command and enter

    tk_dialog

    then enter 

    dump tk_dialog

    it is a sample script

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited December 2016

    found how to take input its easy

    puts 'Enter your name: '
    #flush stdout
    set name [gets stdin]

    puts 'Enter your name: '
    #flush stdout
    set name2 [gets stdin]

    set sum $name

    set sum2 $name2

    puts 'Hello $sum'
    puts 'Hello $sum2'

     

  • tinh
    tinh Altair Community Member
    edited December 2016

    yes, it's easy

    if you need input by GUI, view tk_dialog

  • Pritish Avachat
    Pritish Avachat Altair Community Member
    edited April 2018

    Code for importing geometry in HM is as follows:
     

    *geomimport 'auto_detect' 'Z:/Users/CAD.stp' 'CleanupTol=-0.01' 'DoNotMergeEdges=off' 'ImportBlanked=off' 'ScaleFactor=1.0'

    How can I get these inputs like CAD location, tolerance, scalefactor from user when I run TCL script ? 

  • llyle_20499
    llyle_20499 New Altair Community Member
    edited April 2018

    Hi Pritish,

     

    It will be idea for you to create GUI using TK. You can refer to HW GUI Toolkit

     

    1.    From the Start menu, select All Programs.
    2.    Select Altair HyperWorks.
    3.    Select Tools.
    4.    Select HW GUI Toolkit.
     

    You can also refer to the userguide to get started: 

    https://connect.altair.com/CP/kb-view.html?jf=112968&f=&kb=112938

  • tinh
    tinh Altair Community Member
    edited April 2018

    Code for importing geometry in HM is as follows:
    set filepath [tk_getOpenFile]

    set tolerance [hm_getfloat tolerance input]

    set scalefactor [hm_getfloat scalefactor input]

    *geomimport 'auto_detect' '$filepath' 'CleanupTol=$tolerance' 'DoNotMergeEdges=off' 'ImportBlanked=off' 'ScaleFactor=$scalefactor'

    How can I get these inputs like CAD location, tolerance, scalefactor from user when I run TCL script ? 

     

  • Pritish Avachat
    Pritish Avachat Altair Community Member
    edited September 2018

    Hello Guys,
    Hope you are all doing well ! Your tutoring has helped me a lot in my initial coding.
     
    Now, I am looking to load a tpl file, but before loading I want to take user input for one variable (say span) and use that variable value in formules mentioned in tpl script.
    For that I am thinking to have a window pop up before running tpl file, which will store user input value(span) in one variable ($input)  and then using this $input in further tpl script.

     

    I was able to write this code for poping up window in hypermesh, but this is not working in hyperview when I call same tcl script.
     

    set input [hwtk::inputdialog -text 'Enter Span Value' -inputtype str \
        -x [winfo rootx $w] -y [winfo rooty $w]]

    tk_messageBox -title 'hwtk::inputdialog' -message 'Span: $input mm'

    1. CAN you guys help me to pop up a window in Hyperview which will store data in a variable ?
    2. How to integrate Tpl script in Tcl to achieve my objective ? or any other way to load the tpl file with Step 1 input in it ?


    Awaiting your replies ! 

  • tinh
    tinh Altair Community Member
    edited September 2018

    Please show what the error raised?

  • Pritish Avachat
    Pritish Avachat Altair Community Member
    edited September 2018

    Please show what the error raised?

    <?xml version="1.0" encoding="UTF-8"?>image.thumb.png.02b6b89fa6c8d84bbc6bc336c81c3992.png

  • tinh
    tinh Altair Community Member
    edited September 2018

    Please replace '$w' by '.'

  • Pritish Avachat
    Pritish Avachat Altair Community Member
    edited September 2018

    <?xml version="1.0" encoding="UTF-8"?>image.thumb.png.53069a2e34b27095467f64619cb45af9.png

  • tinh
    tinh Altair Community Member
    edited September 2018

    Tpl does not share variables with tcl

    Suppose sample.tpl is your file

    Add these tcl codes to dip $input in sample.tpl

     

    set fpt [open sample.tpl]

    set buf [read $fpt]

    close $fpt

    set buf [string map '\$input \'$input\'' $buf]

    set fpt [open sample2.tpl w]

    puts $fpt $buf

    close $fpt

     

     

     

    Now open the sample2.tpl

    sample.tpl is reserved

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    Ok I will search for that

     

    But will direct tcl commands work in hyperview script?

     

    And it will be really helpful if you give any example script you have

     

    And will it pop up window or where we supposed to enter values?

    HI,

    I am trying to get data from hyperbeam Eg. IY,IZ of a solid section. Can you please help me with script or command?

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    Hi 

    i dont know direct command

    open window command and enter

    tk_dialog

    then enter 

    dump tk_dialog

    it is a sample script

    HI,

    I am trying to get data from hyperbeam Eg. IY,IZ of a solid section. Can you please help me with script or command?

  • tinh
    tinh Altair Community Member
    edited October 2018

    I searched its datanames but it does not have IY IZ,

    Maybe, you have to create a surface fits with that section , mesh it and use hm_getmoi

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    I searched its datanames but it does not have IY IZ,

    Maybe, you have to create a surface fits with that section , mesh it and use hm_getmoi

    Hi tinh,

    Can you please elaborate the meaning of surface fits?

  • tinh
    tinh Altair Community Member
    edited October 2018

    I mean a surface that fits with the section. Sorry for my english

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    I mean a surface that fits with the section. Sorry for my english

    Hi tinh,

    My hypermesh model contains some Hyperbeam sections. Each section will have associated data like shown below,

     

    Area  =    777.34677330
    Centroid :  
      Local  
        Yc  =    0.00369492
        Zc  =    0.00048295
    Moments Of Inertia :  
      Local  
        IY  =    8385.75207149
        IZ  =    292739.17537076
        IYZ  =    0.00138714
      Centroidal  
        Iy  =    8385.75189018
        Iz  =    292739.16475806
        Iyz  =    0.00000000
      Principal  
        Iv  =    8385.75189018
        Iw  =    292739.16475806
        Angle  =    0.00000000
    How can i get this data to text or any readable file by using command because my model has many such beams and I need to extract this details of all the beams.

    <?xml version="1.0" encoding="UTF-8"?>Captu22re.PNG

  • tinh
    tinh Altair Community Member
    edited October 2018

    I am searching...

    Plz wait

  • tinh
    tinh Altair Community Member
    edited October 2018

    I found command 'hb_getresults'

    But you have to pre-select a section

     

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    I found command 'hb_getresults'

    But you have to pre-select a section

     

    Hi tinh,

    unfortunately its showing hb_getresults as invalid.  

     

  • tinh
    tinh Altair Community Member
    edited October 2018

    You have to enter hyperbeam GUI first-_-/emoticons/default_sleep.png' srcset='/emoticons/sleep@2x.png 2x' title='-_-' width='20' />

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    You have to enter hyperbeam GUI first

    yes tinh, its working now.. thanks a lot...

    I would like to know that is there any command to switche to thyperbeam GUI.

    If it works then it would be very easy to get the required data.

    I am trying with  *createmark beamsects 1 'solid_section.0' ,

    but its not working..hb_getresults will only work if we switch to hyperbeam gui and select the particular beam section and switch back to model gui...

     

  • tinh
    tinh Altair Community Member
    edited October 2018

    Hi

    Try hm_launchhb

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited October 2018

    Hi Tinh,

    Thanks for everything its working successfully....

    Just had one doubt.. Do we have any command to get back to hypermesh gui..(unlaunch hyperbeam)

  • tinh
    tinh Altair Community Member
    edited October 2018

    Sure, we have.

    ::HB_Framework::exit -1

  • Ajinkya Gaikwad
    Ajinkya Gaikwad Altair Community Member
    edited November 2018

    Yes its working successfully..thanks for your help Tinh..

  • brahmadev
    brahmadev Altair Community Member
    edited May 2019

    Sure, we have.

    ::HB_Framework::exit -1

    Hello Tinh,

    where did you find this command ?

     

    I have searched it in the reference manual but couldn't find it.

     

    Also, is there a way to directly export all the available shell section data as CSV format through the TCL script?

     

    thanks and regards,

    Brahmadev.