Find more posts tagged with
Hi Jouher,
example in file c:/users/jouher/hmcustom.tcl
you put these codes:
hm_framework registerproc ::p_CallbackAfterUserProfileChanged after_userprofile
proc ::p_CallbackAfterUserProfileChanged args {
p_CreateDropdown Jouher
#and other codes you want to run after changing profile
}
proc ::p_CreateDropdown Menu {
set main [. cget -menu]
catch {menu $main.mnu$Menu -tearoff 0}
$main add cascade -label $Menu -menu $main.mnu$Menu
return $main.mnu$Menu
}
::p_CreateDropdown Jouher
Hi Tinh,
Below is my code,
############
set mypath 'C:/Users/MYNAME/myscripts'; set top_menu [hm_framework getpulldowns] catch {$top_menu delete [.hmMainMenuBar index 'MyMenu']} catch {destroy $top_menu.custom} menu $top_menu.custom -tearoff 0 $top_menu insert 20 cascade -label 'MyMenu' -menu $top_menu.custom set cat1 $top_menu.custom $cat1 add cascade -label 'Category 1' -underline 0 -menu [menu $cat1.mnu1 -title 'Cat-1'] $cat1.mnu1 add command -label 'Script 1' -command 'source {$mypath/script1.tcl}' -underline 0 $cat1.mnu1 add command -label 'Script 2' -command 'source {$mypath/script2.tcl}' -underline 0 $top_menu.custom add separator set cat2 $top_menu.custom $cat2 add cascade -label 'Category 2' -underline 0 -menu [menu $cat2.mnu2 -title 'Cat-2'] $cat2.mnu2 add command -label 'Script 21' -command 'source {$mypath/script21.tcl}' -underline 0 $cat2.mnu2 add command -label 'Script 22' -command 'source {$mypath/script22.tcl}' -underline 0
####################
how should i add this in your command?
i have done that.
but still it show error after changing the profile as shown in figure.
window name 'summary' already exists in parent
window name 'summary' already exists in parent
while executing
'frame $f'
(file 'C:/Users/Jouher/Desktop/Jouher_custom/hmcustom.tcl' line 13)
There is a frame already in my file.
See the above replies to see my code in file.
see my code also.
proc ::p_CallbackAfterUserProfileChanged args {
source 'C:/Users/Jouher/Desktop/Jouher_custom/hmcustom.tcl'
}
hm_framework registerproc ::p_CallbackAfterUserProfileChanged after_userprofile
::p_CallbackAfterUserProfileChanged
Hello tinh,
I've a problem with custom menu in the HM release 2019. Now the custom menu is not reloading when I import a model, while your code works great with user profile change. I tried to find something in the manual "hm_framework registerproc" but without success.
May you suggest me a code to reload custom menu when I import new models?
Many thanks
Jack LC
Hi Jack,
as I know, when we import a model, HM will not reset its menus.
So your case looks strange. Could you take some photos?
We can register a callback to reload menus after importing new models. But i suggest you first to close HM and delete files .../Documents/hmsettings.tcl; .../Documents/hmmenu.set; .../Documents/command.tcl
then try again
Hi tinh,
thanks tinh for your reply and your suggestions.
To make a test, I created a simplified version of the custom menu. Then I did the following:
1) Delete files hmmenu.set and command.tcl (hmsettings.tcl not present in my starting folder)
2) Open HM, the menu is present
3) Import an abaqus model; as you can see in the picture below, the menu disappeared
The files I used are the following (I'm not an expert, I copied them from your posts):
1) hmcustom.tcl
proc ::p_CallbackAfterUserProfileChanged args { source "C:/Disk_D/Dati/settings/HW/TestMenu.tcl" } hm_framework registerproc ::p_CallbackAfterUserProfileChanged after_userprofile ::p_CallbackAfterUserProfileChanged hm_framework registerproc ::p_CallbackAfterUserProfileChanged after_menudraw ::p_CallbackAfterUserProfileChanged
2) TestMenu.tcl
# # Creation Menu in HM # set TopMenu [hm_framework getpulldowns] catch {$TopMenu delete [.hmMainMenuBar index "TEST"]} catch {destroy $TopMenu.test} menu $TopMenu.test -tearoff 0 $TopMenu insert 20 cascade -label "TEST" -menu $TopMenu.test $TopMenu.test add separator
Since my case is strange, maybe it is related to my HM version (2019.1)
Best regards,
Jack LC
Hi Jack,
i found a registered proc is hooked to import command, so it (calls to) reset menus.
in your hmcustom.tcl :
proc ::p_AddUserMenus args { source "C:/Disk_D/Dati/settings/HW/TestMenu.tcl" } proc ::p_CallbackAfterUserProfileChanged args { #check if Abaqus profile is loaded: if {[string equal -nocase $args Abaqus]} { trace remove execution ::UserProfiles::Abaqus::UpdatePulldowns leave ::p_AddUserMenus trace add execution ::UserProfiles::Abaqus::UpdatePulldowns leave ::p_AddUserMenus } ::p_AddUserMenus } hm_framework registerproc ::p_CallbackAfterUserProfileChanged after_userprofile ::p_CallbackAfterUserProfileChanged
do not register proc for event "after_menudraw", it may hang your hypermesh!
Hi
you have to register a callback:
hm_framework registerproc ::p_CallbackAfterUserProfileChanged after_userprofile
then in body of the callback proc, you reload dropdown menus