Running a script using tcl\tk

Vikas Kumar_22189
Vikas Kumar_22189 Altair Community Member
edited October 2020 in Community Q&A

Can we run a script using tcl\tk script so it will provide all Hypemesh api's without opening Hypermesh.

 

Or can we import package related to Hypermesh script without opening hypermesh or running tool from command prompt.

 

 

image.png.6be8301f322d736f487b8495ceeae5b7.png

Answers

  • tinh
    tinh Altair Community Member
    edited May 2018

    I am not sure. Maybe we can load some *.dll file containing hm api into tcl interp

    try command 'info loaded' to see them

     

    Instead, we can open hm in background so you don't see its GUI but all functions are available.

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited May 2018

    Yes, I have tried this using batch file

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi Jouher,

     

    How it can be done using batch file please let me know.

     

    Thanks and regards

    Vikas Kumar

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi tinh,

     

    While loading any .dll file from hyperworks tclsh stops working and giving error.

     

    image.png.044f339dc130f361060285efeda060eb.png

     

    I am using command     load 'C:/Program Files/Altair/14.0/hm/bin/win64/hwatnetworkdiagram_tcl.dll'      and i am using tclsh 8.6 version.

     Thanks

  • tinh
    tinh Altair Community Member
    edited June 2018

    Hi,

    maybe the file is loaded by hm. it needs other dependent libraries

    I don't see any tcl command loading it

    so other tcl version is also not able to load it.

     

     

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited June 2018

    Hi Vikas,

    Create a batch file by Following this procedure:

     

    d: (drive where Altair HM is installed)
    Altair\14.0\hw\tcl\tcl8.5.9\win64\bin\wish85 \\PATHofTCL\Main_file.tcl

     

    Thus it will look like

    d:
    Altair\14.0\hw\tcl\tcl8.5.9\win64\bin\wish85 \\XYZ\Main_file.tcl

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi Jouher,

     

    After that how to call .batch file and what will be content of batch file.

    I have given this but it's not working i am running .bat file by using command  'exec batFile.bat' in tclsh prompt.

     

    C:\Program Files\Altair\13.0\hw\tcl\tcl8.5.9\win64\bin\wish85\\D:\Vikas\Backup\TCL_TK\checkExit.tcl

     

    It is showing 

    image.png.ce7649881cc5b7ea089dd83584e7182a.png

     

     

    Thanks

  • tinh
    tinh Altair Community Member
    edited June 2018

    Hi Vikas,

    it is clear that you need quotes because your path has a space

    'C:\Program Files\Altair\13.0\hw\tcl\tcl8.5.9\win64\bin\wish85' D:\Vikas\Backup\TCL_TK\checkExit.tcl

     

    if path of your tcl file has spaces, you need to quote it, too

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Only in C directory altair path has space but i kept it like

     

    'C:/Program Files/Altair/13.0/hw/tcl/tcl8.5.9/win64/bin/wish85.exe' 'D:/Vikas/Backup/TCL_TK/checkExit.tcl' 

     

    still it's not working

  • tinh
    tinh Altair Community Member
    edited June 2018

    Please show your 'checkExit.tcl' content?

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    A simple code ..

     

    wm protocol . WM_DELETE_WINDOW chk_exit
      proc chk_exit {} {
        set ans [tk_messageBox -type yesno -icon question -message 'Are you sure you want to quit?']
        if { $ans != 'no' } {
             exit
           }
      };# chk_exit

     

     

  • tinh
    tinh Altair Community Member
    edited June 2018

    I tested. It worked!

    what is error in your case?

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited November 2020

    It is showing 

     

    image.png.2c69bae7daae1d3efb3ef6e6ebe9e32c.png

     

    But file exist at given location .

     

    My batch file I am attaching with this.

    Unable to find an attachment - read this blog

  • tinh
    tinh Altair Community Member
    edited June 2018

    Hi,

    there is abnormal characters in your path:

    Capture.PNG.a8c44b2196f8314bcd2b5ce4f2e3558d.PNG

     

    Maybe, encoding problem.

    Try open notepad and edit batch file again

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited November 2020

    Hi tinh,

     

    i have uploade batch file too you can see there is no such character available

     

     

    Unable to find an attachment - read this blog

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi Tinh,

     

    It's working if i am changing format of directory name to 

     

    'C:\Program Files\Altair\13.0\hw\tcl\tcl8.5.9\win64\bin\wish85.exe' 'D:\Vikas\Backup\TCL_TK\checkExit.tcl'

     

    instead of 'forwad slash ( / )' i am using 'Back slash (\)' .

     

    Thanks for your support

     

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi Tinh,

     

    Now i am trying to run same .tcl file as file -> Run -> TCL\TK Script in HM by using this command

     

    'C:\Program Files\Altair\13.0\hm\bin\win64\hmopengl.exe' 'D:\Vikas\Backup\TCL_TK\checkExit.tcl'

     

    but it's only opening the Hypermesh. And not running the checkExit.tcl file.

    tinh or jouhar could you help me out to run the script.

     

    Regards,

    Vikas 

  • tinh
    tinh Altair Community Member
    edited June 2018

    The target command should be

    (has ' -tcl ' with spaces before the tcl file)

    'C:\Program Files\Altair\13.0\hm\bin\win64\hmopengl.exe' -tcl 'D:\Vikas\Backup\TCL_TK\checkExit.tcl'

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi tinh,

     

    Thanks for your support now it's working.

    Thanks alot.

     

    Best regards,

    Vikas

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    Hi tinh,

    May i get some more information on this.

    How you identified that there will be '-tcl' in between please if it is possible explain or share the link i will go through

     

    Regards 

    Vikas Kumar

  • tinh
    tinh Altair Community Member
    edited June 2018

    Well, this question is much more difficult than your previous question !

    I know it for really long time ago (maybe version 8), so looking for it again was so tough :wacko:/emoticons/default_wacko.png' title=':wacko:' />

    You should spend your time to read all hm help documents!

     

    in hm help > altair help home > hyperworks desktop applications > getting started >

    hyperworks desktop overview > startup procedures and customization > starting hyperworks desktop application > hypermesh startup options

  • Vikas Kumar_22189
    Vikas Kumar_22189 Altair Community Member
    edited June 2018

    @tinh

     

    Thanks