TCL : Is there any command or syntax for pause & play the script file while executing???

RAJA R
RAJA R Altair Community Member
edited June 2022 in Community Q&A

Hi,

I was new to this automation using TCL\TK language. I have a script file where I need to do some manual work into the HyperMesh window while executing the script. So is there any syntax or command we can give for partially pausing the script file for doing manual work & to play the script for rest of the process.

Thanks & regards,

Raja R.

Tagged:

Best Answer

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited June 2022 Answer ✓
    RAJA R said:

    Hi tinh,

    Actually I need to pause\play the script execution temporarily(For example:10mins) for doing some manual operations in HyperMesh. So can you kindly help me out that how it can be done with a demo script???

    Thanks & regards,

    Raja R.

    Tinh is right, using after is not a good idea because if you get interrupted, or the steps take longer, then you may have to start over.  Or if you do it really fast then you may have to wait for the script.

    The 2 ways I thought of is to just have to separate scripts: run one, do the manual steps then run the other one.

    Or as in the attached you can have a dialog come up that will run more code when the user hits "ok".

    Also as Tinh suggests, it may be even better to just incorporate the manual steps into your code.  To get ideas for how to do this you could clear the command.tcl file, do the manual steps and then check the command.tcl for commands to incorporate the manual steps in your code.  Even if it is mostly manual you have more control and can preserve any data you might need from those steps.

Answers

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited June 2022

    First thing that comes to mind for me is a dialog box where you could just hit a button when done.  What are you doing though?  Maybe the manual part could be semi-automated with user inputs.  There is the after command too but that would only give you a set amount of time.

    Attached is an example of a dialog box that could do this.

  • RAJA R
    RAJA R Altair Community Member
    edited April 2022

    First thing that comes to mind for me is a dialog box where you could just hit a button when done.  What are you doing though?  Maybe the manual part could be semi-automated with user inputs.  There is the after command too but that would only give you a set amount of time.

    Attached is an example of a dialog box that could do this.

    Hello Ben,
    Thanks for the information. I was doing an semi-automated script with user inputs. So as you told I will try with after command within sript.

    Thanks & Regards,

    Raja

  • tinh
    tinh Altair Community Member
    edited May 2022
    RAJA R said:

    Hello Ben,
    Thanks for the information. I was doing an semi-automated script with user inputs. So as you told I will try with after command within sript.

    Thanks & Regards,

    Raja

    don't do that! to input something to script, you can use: hm_getint hm_getfloat hm_getstring *createmarkpanel ... the command "after" is just to delay without interaction, or to create timer for advance, you can use tkwait, then you can interact GUI, but careful if you modifying some entities that script will refer to
  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited May 2022
    tinh said:

    don't do that! to input something to script, you can use: hm_getint hm_getfloat hm_getstring *createmarkpanel ... the command "after" is just to delay without interaction, or to create timer for advance, you can use tkwait, then you can interact GUI, but careful if you modifying some entities that script will refer to

    Agreed. Sorry for the misleading suggestion.

  • RAJA R
    RAJA R Altair Community Member
    edited May 2022
    tinh said:

    don't do that! to input something to script, you can use: hm_getint hm_getfloat hm_getstring *createmarkpanel ... the command "after" is just to delay without interaction, or to create timer for advance, you can use tkwait, then you can interact GUI, but careful if you modifying some entities that script will refer to

    Hi tinh,

    Actually I need to pause\play the script execution temporarily(For example:10mins) for doing some manual operations in HyperMesh. So can you kindly help me out that how it can be done with a demo script???

    Thanks & regards,

    Raja R.

  • Ben Buchanan
    Ben Buchanan
    Altair Employee
    edited June 2022 Answer ✓
    RAJA R said:

    Hi tinh,

    Actually I need to pause\play the script execution temporarily(For example:10mins) for doing some manual operations in HyperMesh. So can you kindly help me out that how it can be done with a demo script???

    Thanks & regards,

    Raja R.

    Tinh is right, using after is not a good idea because if you get interrupted, or the steps take longer, then you may have to start over.  Or if you do it really fast then you may have to wait for the script.

    The 2 ways I thought of is to just have to separate scripts: run one, do the manual steps then run the other one.

    Or as in the attached you can have a dialog come up that will run more code when the user hits "ok".

    Also as Tinh suggests, it may be even better to just incorporate the manual steps into your code.  To get ideas for how to do this you could clear the command.tcl file, do the manual steps and then check the command.tcl for commands to incorporate the manual steps in your code.  Even if it is mostly manual you have more control and can preserve any data you might need from those steps.

  • tinh
    tinh Altair Community Member
    edited June 2022
    RAJA R said:

    Hi tinh,

    Actually I need to pause\play the script execution temporarily(For example:10mins) for doing some manual operations in HyperMesh. So can you kindly help me out that how it can be done with a demo script???

    Thanks & regards,

    Raja R.

    Hi, I am sure that I have posted a sample script on this forum, if you could search with keyword "tkwait", it is good. a similar one is: ... #insert below lines anywhere you want to pause: #pause temporary: set ::pause 1 tkwait variable ::pause #now you can manually do something with hyper #if you want to continue script, open command window and enter: set ::pause 0
  • tinh
    tinh Altair Community Member
    edited May 2022
    tinh said:

    Hi, I am sure that I have posted a sample script on this forum, if you could search with keyword "tkwait", it is good. a similar one is: ... #insert below lines anywhere you want to pause: #pause temporary: set ::pause 1 tkwait variable ::pause #now you can manually do something with hyper #if you want to continue script, open command window and enter: set ::pause 0

    sorry, i use a smarphone so i cannot type it clearly you can refer to tk manual for command tkwait