Run Command on Open for HyperView
Best Answer
-
Blake Berk said:
Hi Paul,
The last thing you said is what I am interested in - creating a "permanent" button to run a macro. Do you know how to add that to the preference file? When I save a standard .mvw with the button added, it does not add it to the .mvw 'code.'
Thanks for your time so far! Let me know if you have code to assist the creation of a button or tool bar addition.
Best,
Blake
Ok, I created a generic annotated preferences file for you (attached) with a few of the alternatives for menus/buttons, depending on what your tcl is doing, one of these may be more appropriate than the others, you ought to be able to hack it to do what you want (edit the tcl references, remove anything you don't need), it includes menu options for both hyperview and hypergraph, It is possible to make submenus etc if needed, this is just a simple example.
To use it, download it, put it somewhere sensible (e.g. create an 'AltairPrefs' Folder somewhere)
Then in hyperview/graph, go to load --> Preference File
Click 'Register' and browse to the mvw you saved, and 'open' it
It should then appear in the list of preferences, you can pick it and click 'Load', this should be 'sticky' i.e. the selected prefs file is loaded by default on every HV/HG launch.
It will mostly work straight away, but at this point, to make sure, it is worth closing/reopening HV/HG
In HyperView Client, you should now have a menu dropdown called 'MyMacro' with a single entry (points to a tool built into the installation)
And in HyperGraph Client a similar dropdown, this time with 2 entries, one for the same tool, one for a shortcut to a filter macro
also in Hypergraph, there should be 2 other menus
A 'My Macro' Menu on right clicking a curve in the browser (performs tasks on that curve)
And a 'My Macro' Menu on right clicking a curve in the graphics area (performs tasks on that curve)
You can edit this, unregister/register it, load it, as many times as you need to, it is worth doing a close/open on HV/HG to check it too, and see what you get, if you break things don't worry, you can just 'load' the default settings back again and try something else.
Good luck!
if you have a play with this and can't get it doing what you want, get back to me!
1
Answers
-
You can create, register and load a preference file
Below is mine for example:
// HWVERSION_HW11.0.120-HWDesktop_Mar 5 2012_10:15:53 // Preference file for Altair HyperWorks // Please use "Set Preferences File..." // under the File menu for specifying this customized preferences file. *Id("HyperWorks v8.0") {mvp_toolbar_dir = "D:/AltairTemp/Macros/MVP_Toolbar";include(mvp_toolbar_dir + "/preferences_macro.mvw")} {include("D:/AltairWin64/HW2021.2/hwdesktop/utility/VehicleSafetyTools/mv_hv_hg/vst.mvw")} {include("D:/AltairTemp/Macros/VPI_Calc/VPI_Calc_V1.0.mvw")} {include("D:/AltairTemp/Macros/SpragueAndGeers/Sprague-Geers.mvw")} *BeginGraphicDefaults() *BeginContextMenu(viewFlip, "Flip View") *ContextMenuItem(viewFlip,"Flip Horizontal","D:/AltairTemp/MACROS/FlipHorizVert/flipViewHorVer.tcl",::cMenu::flipHorizontal, animation) *ContextMenuItem(viewFlip,"Flip Vertical","D:/AltairTemp/MACROS/FlipHorizVert/flipViewHorVer.tcl",::cMenu::flipVertical, animation) *EndContextMenu() *NoteForeGroundColor("Black") *DefaultPostContourLegendFile ("D:/AltairTemp/MACROS/Legend/LegendPref2017.tcl") //*SetOrientation(Top) //*SetBackgroundColor(0) //*Part(Default, On, IdOn, 12, Opaque, Shaded, NoTrace) *EndGraphicDefaults() *Id("HyperWorks", "11.*") //*BeginAnimator(Static) // *CurrentPosition(0) // *NumberOfSteps(100) // *Increment(Forward, Frame, 1, BounceOn) //*EndAnimator() *BeginDefaults() *BeginPlotDefaults() *SetPreloadMaximum(1000000000) *EndPlotDefaults() *EndDefaults() //*EndGraphicDefaults() *BeginPlot3DDefaults() *SetPreloadMaximum(1000000000) *EndPlot3DDefaults()
0 -
Hi Paul,
This looks great! Appreciate the support.
Do you know how to execute a TCL function directly from this preference file? I am looking to run a macro I have already created. This preference file looks like another syntax to learn (with limited documentation?) and I already have quite a few lines of code associated with the TCL function!
Thanks,
Blake
0 -
Blake Berk said:
Hi Paul,
This looks great! Appreciate the support.
Do you know how to execute a TCL function directly from this preference file? I am looking to run a macro I have already created. This preference file looks like another syntax to learn (with limited documentation?) and I already have quite a few lines of code associated with the TCL function!
Thanks,
Blake
What task are you trying to do on start up? What are you trying to do with the TCL? If the tcl is performing something on a model then the model would need to be loaded first? i.e. is this an automated post processing task? in that case it might be better executed with a report template?
If you can describe your end goal then there might be a better way of getting there!
The Preferences mvw can pre-load your macros and put them into menus for you so they are ready to use e.g. below from the MVP toolbar but it can't run them on its own, it is a 'settings' loader effectively.
1 -
Paul Sharp_21301 said:
What task are you trying to do on start up? What are you trying to do with the TCL? If the tcl is performing something on a model then the model would need to be loaded first? i.e. is this an automated post processing task? in that case it might be better executed with a report template?
If you can describe your end goal then there might be a better way of getting there!
The Preferences mvw can pre-load your macros and put them into menus for you so they are ready to use e.g. below from the MVP toolbar but it can't run them on its own, it is a 'settings' loader effectively.
Hi Paul,
The last thing you said is what I am interested in - creating a "permanent" button to run a macro. Do you know how to add that to the preference file? When I save a standard .mvw with the button added, it does not add it to the .mvw 'code.'
Thanks for your time so far! Let me know if you have code to assist the creation of a button or tool bar addition.
Best,
Blake
0 -
Blake Berk said:
Hi Paul,
The last thing you said is what I am interested in - creating a "permanent" button to run a macro. Do you know how to add that to the preference file? When I save a standard .mvw with the button added, it does not add it to the .mvw 'code.'
Thanks for your time so far! Let me know if you have code to assist the creation of a button or tool bar addition.
Best,
Blake
Ok, I created a generic annotated preferences file for you (attached) with a few of the alternatives for menus/buttons, depending on what your tcl is doing, one of these may be more appropriate than the others, you ought to be able to hack it to do what you want (edit the tcl references, remove anything you don't need), it includes menu options for both hyperview and hypergraph, It is possible to make submenus etc if needed, this is just a simple example.
To use it, download it, put it somewhere sensible (e.g. create an 'AltairPrefs' Folder somewhere)
Then in hyperview/graph, go to load --> Preference File
Click 'Register' and browse to the mvw you saved, and 'open' it
It should then appear in the list of preferences, you can pick it and click 'Load', this should be 'sticky' i.e. the selected prefs file is loaded by default on every HV/HG launch.
It will mostly work straight away, but at this point, to make sure, it is worth closing/reopening HV/HG
In HyperView Client, you should now have a menu dropdown called 'MyMacro' with a single entry (points to a tool built into the installation)
And in HyperGraph Client a similar dropdown, this time with 2 entries, one for the same tool, one for a shortcut to a filter macro
also in Hypergraph, there should be 2 other menus
A 'My Macro' Menu on right clicking a curve in the browser (performs tasks on that curve)
And a 'My Macro' Menu on right clicking a curve in the graphics area (performs tasks on that curve)
You can edit this, unregister/register it, load it, as many times as you need to, it is worth doing a close/open on HV/HG to check it too, and see what you get, if you break things don't worry, you can just 'load' the default settings back again and try something else.
Good luck!
if you have a play with this and can't get it doing what you want, get back to me!
1 -
Paul Sharp_21301 said:
Ok, I created a generic annotated preferences file for you (attached) with a few of the alternatives for menus/buttons, depending on what your tcl is doing, one of these may be more appropriate than the others, you ought to be able to hack it to do what you want (edit the tcl references, remove anything you don't need), it includes menu options for both hyperview and hypergraph, It is possible to make submenus etc if needed, this is just a simple example.
To use it, download it, put it somewhere sensible (e.g. create an 'AltairPrefs' Folder somewhere)
Then in hyperview/graph, go to load --> Preference File
Click 'Register' and browse to the mvw you saved, and 'open' it
It should then appear in the list of preferences, you can pick it and click 'Load', this should be 'sticky' i.e. the selected prefs file is loaded by default on every HV/HG launch.
It will mostly work straight away, but at this point, to make sure, it is worth closing/reopening HV/HG
In HyperView Client, you should now have a menu dropdown called 'MyMacro' with a single entry (points to a tool built into the installation)
And in HyperGraph Client a similar dropdown, this time with 2 entries, one for the same tool, one for a shortcut to a filter macro
also in Hypergraph, there should be 2 other menus
A 'My Macro' Menu on right clicking a curve in the browser (performs tasks on that curve)
And a 'My Macro' Menu on right clicking a curve in the graphics area (performs tasks on that curve)
You can edit this, unregister/register it, load it, as many times as you need to, it is worth doing a close/open on HV/HG to check it too, and see what you get, if you break things don't worry, you can just 'load' the default settings back again and try something else.
Good luck!
if you have a play with this and can't get it doing what you want, get back to me!
Awesome! Thank you! This worked as desired!
0