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