User input to Batchmesh criteria and parameter file using TCL/TK
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
@Q.Nguyen-Dai Yes, Basic programming.
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?
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
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 ¶m_file;
} else \
{
tk_messageBox -message 'File dosnt exist';
}
}
Thank You so much both of you, @tinh and @Pandurang
It's working perfectly!
Do you know something about Tcl programming?