🎉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

Auto closing hm session

User: "vipin_22401"
Altair Community Member
Updated by vipin_22401

I want to terminate the hm session if it is idle for more than one hour.

Is there any option available inside the license file? Or else what is the alternative?

Find more posts tagged with

Sort by:
1 - 17 of 171
    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    License file, I don't know. But with License server, it seams that's possible. I'm not sure.

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi

    What do you mean 'idle'?

    Suppose that you want to close if over 1h there is no user interaction on hm session:

    Try a proc like this

    proc ::p_MonitorHmSession {TriggerTime TriggerScript} {

             if {[focus] ne ''} {

                     dict set ::p_MonitorHmSession -lastused [clock seconds]

              } else {

                     if {[clock seconds]-[dict get $::p_MonitorHmSession -lastused]>$TriggerTime*3600} {

                              uplevel #0 $TriggerScript

                              dict set ::p_MonitorHmSession -lastused [clock seconds]

                     }

              }

              after cancel [list ::p_MonitorHmSession $TriggerTime $TriggerScript]

              after 5000 [list ::p_MonitorHmSession $TriggerTime $TriggerScript]

    }

    now start the monitor:

    ::p_MonitorHmSession 1 hm_exit; #after 1hour if do not focus on hm window, it will exit

    User: "vipin_22401"
    Altair Community Member
    OP
    Updated by vipin_22401

    Hi,

     

    Thanks a lot for the script, this is what i exactly looking for.

    I have added the command to save the file in some location before closing.

    User: "Roshan Shiveshwar"
    Altair Community Member
    Updated by Roshan Shiveshwar

    Hi,

    If I run a HM script that runs for more than $TriggerTime hrs and minimize the HM window, will HM get closed ? or will it wait for the script to be completed?

     

    Regards,

    Roshan

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Try it!

     

    if your script calls to command 'update' then hm will run the monitor proc and may trigger -> close hm

    User: "vipin_22401"
    Altair Community Member
    OP
    Updated by vipin_22401

    Hi @tinh,

     

    If I open two or more hypermesh windows(with script in hmcustom.tcl), the script is closing the window which is on top(please see image below).

    After that it is not closing other windows. I am not keeping any focus on the windows.

     

    Script is working fine if there is only 1 hm session present. But i need to close all the sessions which are not in use. Is there any solution for this?

     

    <?xml version="1.0" encoding="UTF-8"?>image.thumb.png.cef8697985abf48dd64cb81c5fa46a2d.png

     

     

     

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Vipin

    You have to run the script on all hm sessions

    put the script in a file named hmcustom.tcl in folder c:\users\your_account

    hm will run it when opening

    User: "vipin_22401"
    Altair Community Member
    OP
    Updated by vipin_22401

    Hi tinh,

     

    Yes I did the same, but after the first window is closed it is not working on other windows. If all windows are minimized it will work.

    Only problem is if i keep windows like the above image it is not working.

    User: "tinh"
    Altair Community Member
    Updated by tinh

    I see, it's because when one session was closed, window focus in next one so it seems to get 'interaction' with user.

    minimizing all can avoid this, or open other window on top (eg. notepad)

     

    or modify script that before exiting then tells other sessions not to get focus

    User: "Roshan Shiveshwar"
    Altair Community Member
    Updated by Roshan Shiveshwar

    Hi,

    If I have to extend this to Hyperview , in which file  should I place this code?

     

    Thanks,

    Roshan

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi

    save the codes in any file, example C:\mystartup.tcl

     

    right click on HV icon and select Properties

    in Target field add arguments:

    -tcl C:\mystartup.tcl

     

     

    User: "Roshan Shiveshwar"
    Altair Community Member
    Updated by Roshan Shiveshwar

    Hi,

     

    For HV 14 ,  I found another way where I can place the code in 'hwstartup.tcl'. This file is available in '.\..\HW14.0\hw\tcl' directory. 

    'hwstartup.tcl' gets executed whenever HV gets launched.

     

    Unfortunately, this tcl file is not available for HV 13 n below.  Any idea what other files I can try with?

     

    Thanks,

    Roshan

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Roshan

    you can put the codes in

    c:/users/your_account/hwinit.tcl

     

    User: "Roshan Shiveshwar"
    Altair Community Member
    Updated by Roshan Shiveshwar

    Hi tinh,

     

    I tried with hwinit.tcl . But, I 'm getting this error.  Not sure why?

     

    image.png.0b85fff7fc2e45354be557b83c565504.png

     

    UPDATE : I had put the code in  '.\..\HW14.0\hw\tcl\hwinit.tcl'.

     

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Roshan,

    it because at sourcing time there is no GUI

    please add this line at beginning of hwinit.tcl :

     

    dict set ::p_MonitorHmSession -lastused [clock seconds]

    User: "Roshan Shiveshwar"
    Altair Community Member
    Updated by Roshan Shiveshwar

    Thanks tinh !!

    That was helpful.

    User: "Ajay Prabhakaran"
    Altair Community Member
    Updated by Ajay Prabhakaran

    Hello Tinh

     

    Do you have any idea how to run a tcl script before starting Hyperworks. hmcustom.tcl will run after Hyperworks GUI is loaded.

    I am using Hyperorks 2022.3.

    My idea is to update the extension file before the HW GUI is loaded