🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

User input to Batchmesh criteria and parameter file using TCL/TK

User: "Pritish Avachat"
Altair Community Member
Updated by Pritish Avachat

Hello,

Below is the code to take input from user and store to variable $input

I want to run batchmesh script using this mesh size from user input.
Thank You for any help in this regard

 

set input [hwtk::inputdialog -text 'Enter Average Mesh Size' -inputtype str \
    -x [winfo rootx .] -y [winfo rooty .]]


Also, Can we modify above code to ensure that user inputs only numbers and not text.

Thank You !
Pritish

Find more posts tagged with

Sort by:
1 - 9 of 91
    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    Do you know something about Tcl programming?

    User: "Pritish Avachat"
    Altair Community Member
    OP
    Updated by Pritish Avachat

    @Q.Nguyen-Dai Yes, Basic programming.

    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    There're a lot of free Doc/Tuto of Tcl/Tk programming on Internet.

    User: "Pritish Avachat"
    Altair Community Member
    OP
    Updated by Pritish Avachat

    With Due respect, Thank you for telling me that there is enough on internet.
    It will be very helpful if you guide me regarding my question context.
    If you know, maybe providing a sample code or reference file.

    User: "tinh"
    Altair Community Member
    Updated by tinh

    To ensure input is numeric, provide -inputtype as real

    To run batch with that mesh size, make a criteria file based on the mesh size, it's a text file. If you dont know how to make, use criteria editor to generate multiple files save them as 5mm.criteria,  6mm.criteria , ...

    You need parameter files also.

     

    Once you have files Xmm.criteria and files Xmm.param , run batch by

    *createmark surfs 1 all

    *hm_batchmesh 1 &{input}mm.criteria &{input}mm.param

     

    Can you do it?

     

     

    User: "Pritish Avachat"
    Altair Community Member
    OP
    Updated by Pritish Avachat

    Hello Tinh,

    Thanks a lott for your help with inputtype.
    I am able to create different criteria and parameter files, as well as I know the commands to run batchmesh.

    My query is, suppose I have created three files with 5mm, 6mm, 10mm.
    When I run a tcl script, a pop-up should come up (3 buttons) asking user which mesh size to be used(5/6/10mm) as per the user input respective files will be called, and the pop up window will dismiss.
    I am taking help of 'Dialog' code from hwtk studio, but not helping perfectly.

    Can you help with for this code ?

    Thanks in advance!
    Pritish

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Why don't tell about it first?

     

     

    It is a basic tk proc:

    tk_dialog .dialog Hypermesh 'Select criteria:' '' 0 5mm 6mm 10mm Cancel

     

    User: "Pandurang"
    Altair Community Member
    Updated by Pandurang

    Hi Pritish,

    please try this:)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />:

     

    set user_input [tk_dialog .dialog Hypermesh 'Select criteria:' '' 0 5mm 6mm 10mm Cancel]

    if {$user_input == 0}\
    {
        # this is for 5mm
        # please give full path of criteria and param file
        set criteria_file 5mm.criteria 
        set param_file 5mm.param

    } elseif {$user_input == 1}\
    {
        ## this is for 6mm
        set criteria_file 6mm.criteria 
        set param_file 6mm.param

    } elseif {$user_input == 2}\
    {
        ## this is for 10mm
        set criteria_file 10mm.criteria 
        set param_file 10mm.param

    }

    if {[info exist criteria_file] & [info exist param_file] } \
    {
        if {[file exist $criteria_file] & [file exist $param_file] }\
        {
            *createmark surfs 1 all

            *hm_batchmesh 1 &criteria_file  &param_file;
            
        } else \
        {
            tk_messageBox -message 'File dosnt exist';
        }
        
    }

     

     

    User: "Pritish Avachat"
    Altair Community Member
    OP
    Updated by Pritish Avachat

    Thank You so much both of you, @tinh and @Pandurang
    It's working perfectly!