Need to create cancel button in a pop up to terminate the script
Hello,
I am new to TCL script. I am trying to create a TCL script to isolate 2D element in assembly with a pop up having "Proceed" button to proceed further in a script.
Objective is : If user runs the script, script will isolate 2D element with a pop notification. This will pause the script and user can see the 2D elements in workspace. If user clicks the" proceed" button, script will proceed further. In case, if user clicks "Cancel button", script will terminate.
I need to add a "Cancel" button along with "Proceed" button in below script. Can anyone help me in this?
proc Isolate2D {{opt all}} {
*displaynone
*createmark elems 1 $opt
*createmark elems 2 "by config" tria3 quad4 tria6 quad8
*markintersection elems 1 elems 2
if {[hm_marklength elems 1]} {
*findmark elems 1 0 1 elems 0 2
# This procedure creates a popup that pauses the script execution
proc pauseScript {} {
# Create a toplevel window
toplevel .pause
wm title .pause "2D Elements"
# Create a label with instructions
label .pause.label -text "2D Elements Exists. The script is paused to check. Please rotate the model in workspace to isolate 2D.
Click Proceed to continue."
pack .pause.label
# Create an OK button that resumes the script
button .pause.ok -text "Proceed" -command {
# Destroy the popup window
destroy .pause
# Set the pause variable to 0 to resume the script
set ::pause 0
}
pack .pause.ok
# Set the pause variable to 1 to pause the script
set ::pause 1
# Wait for the pause variable to change before continuing
tkwait variable ::pause
}
# Main script execution starts here
# Call the pauseScript procedure to pause the script
pauseScript
} else {
Message "No 2D elements";
}
*clearmark elems 1
*clearmark elems 2
}
Isolate2D
Answers
-
Hello @Saravanan R ,
did you look at tk_dialog command:tk_dialog manual page - Tk Built-In Commands (tcl.tk)
Could that help here?
That said, we just introduced Python in HyperWorks from version 2023. It was first for HyperView/HyperGraph, and it will be enabled for HyperMesh with the version 2024 we will release soon.
We will still continue to support tcl, but it seems to us like a pivot moment, especially for the users new to automation, to start getting familiar with HyperWorks automation with Python rather than tcl. Especially as Python is the industrial standard and is easier to deal with for GUI based automations.
Hope this helps,
Michael
1 -
Michael Herve_21439 said:
Hello @Saravanan R ,
did you look at tk_dialog command:tk_dialog manual page - Tk Built-In Commands (tcl.tk)
Could that help here?
That said, we just introduced Python in HyperWorks from version 2023. It was first for HyperView/HyperGraph, and it will be enabled for HyperMesh with the version 2024 we will release soon.
We will still continue to support tcl, but it seems to us like a pivot moment, especially for the users new to automation, to start getting familiar with HyperWorks automation with Python rather than tcl. Especially as Python is the industrial standard and is easier to deal with for GUI based automations.
Hope this helps,
Michael
Thank you for the prompt response.
0