Adding DropDown Menu to HyperView Menu Bar
Hello alls,
I want to create a menu entry in HyperView 2019 Menu line (File Edit View Results ... ) providing quick access to some macros. As I understand, this will be realized by creating a preference file which shall be loaded (File -> Load -> Preference File): first "register" file and than "load" file.
I have created such a preference file and has added it to the preferences list. This file includes following code:
*Id("HyperWorks", "2019")
*BeginDefaults()
*BeginPlotDefaults()
*BeginMenu(dummy, "MA Post")
*MenuItem(dummy, "vonMises", TCL, "C:/temp/vonMises.tcl")
*EndMenu()
*EndPlotDefaults()
*EndDefaults()
=> but: nothing is shown in HyperView
I have tried code with " and ' => no effect
I have tried different entries vor *Id() => no effect
Can anybody tell me, how preference file has to look like to create a new menu(button) in menu bar calling a tcl script? I've searchd in Forum, but some promising links I found were no more accessable...
Thank you very much
and best regards
Manuel
Answers
-
Hi
I am not sure about problem with your preference file. HW should parse it and build tk menus
you can make tk menus directly by tk and save it to a tcl/tk file, then call it from File>Run>Tcl/Tk
example file hv_prefs.tcl:
set mnuMain [. cget -menu]
catch {$mnuMain delete "MA Post"}
set mnuAdd [menu $mnuMain.mnuAdd
$mnuMain add cascade -label "MA Post" -menu $mnuAdd
$mnuAdd add command -label "vonMisses" -command {source "C:/temp/vonMises.tcl"}
1 -
Hello Tinh,
thanks for you answer - and as a work around it works..
But I have spend some more time checking the pref-files of HW itself and I found my error:
*BeginPlotDefaults(): this is for Menu in HyperGraph..
*BeginGraphicDefaults(): and this is for Menu in HyperView....
best regards
Manuel
0 -
Hello
I want to add the code you mentioned above for menu creation to hyperworks default preference file so that the drop down menu is available on starting HyperView. Is this possible? If yes, to which file the code should be appended?
Thanks in advance.
0 -
Hello Varsha,
my suggestion is to use the below env. variable
set HW_CONFIG_PATH=C:\yourfolder\
where in the specified folder you will place a preference.mvw file [you have to use this very specific name] in which you can add the menu statements (and as well other settings).
In my experience it is always better to not overwrite directly the installation files.
Extra tip: I usually work with batch files to start my applications, and so I directly use the above statement directly in that file without "polluting" the overall env. variable settings.
Hope this helps.
Regards
Michele
1 -
Michele Macchioni said:
Hello Varsha,
my suggestion is to use the below env. variable
set HW_CONFIG_PATH=C:\yourfolder\
where in the specified folder you will place a preference.mvw file [you have to use this very specific name] in which you can add the menu statements (and as well other settings).
In my experience it is always better to not overwrite directly the installation files.
Extra tip: I usually work with batch files to start my applications, and so I directly use the above statement directly in that file without "polluting" the overall env. variable settings.
Hope this helps.
Regards
Michele
@Michele Macchioni Thank you very much for the guidance.
0 -
I have a tcl script that can create an extra menu button in the menu bar. But the script needs to be executed every time after launching the HyperView application to create the menu button.
I want the script to be executed automatically when I launch the HyperView application.
So which file should I use to source my TCL script and which directory should this file be copied to?
0 -
for adding a menu button, you have to create a prefernces file (*.mvw).
This file you have to register and load in Hyperview, once only: File => Load => Prefercence File
In preference file itself, you can define buttons, which shall be added to menu bar:
*Id("HyperView v10.0")
*BeginDefaults()
*BeginGraphicDefaults() //for HyperView
*BeginMenu(manmenu, "&Test Post")
*BeginMenu(legendcolors, "&Contour Only")
*MenuItem(legendcolors, "&vonMises",TCL, {".../vonMises.tcl"})
*EndMenu()
*BeginMenu(contourplots, "&Full Plots")
*MenuItem(contourplots, "&vonMises",TCL, {".../P_vonMises.tcl"})
*EndMenu()
*EndMenu()
*EndGraphicDefaults()
*EndDefaults()
{tcleval("hw browser delete {Test Post}")}best regards
Manuel
1 -
Manuel Armbruester said:
for adding a menu button, you have to create a prefernces file (*.mvw).
This file you have to register and load in Hyperview, once only: File => Load => Prefercence File
In preference file itself, you can define buttons, which shall be added to menu bar:
*Id("HyperView v10.0")
*BeginDefaults()
*BeginGraphicDefaults() //for HyperView
*BeginMenu(manmenu, "&Test Post")
*BeginMenu(legendcolors, "&Contour Only")
*MenuItem(legendcolors, "&vonMises",TCL, {".../vonMises.tcl"})
*EndMenu()
*BeginMenu(contourplots, "&Full Plots")
*MenuItem(contourplots, "&vonMises",TCL, {".../P_vonMises.tcl"})
*EndMenu()
*EndMenu()
*EndGraphicDefaults()
*EndDefaults()
{tcleval("hw browser delete {Test Post}")}best regards
Manuel
but @Manuel Armbruester I already have a tcl plugin that creates a menu button for my script. I want to know how to load the script every time automatically after the launch of Hyperview application.
For Hypermesh I have solved this by using hmcustom.tcl in My Documents folder and am able to automatically invoke the plugins after startup.
So is there any similar type of solution where I can call my TCL file to some custom folder?
0