πŸŽ‰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

how to create a dropdown menu in Hyperworks X using TCL commands

In Hyperworks X 2021, I would like to create a dropdown menu which looks something like this.

Instead of using XML extensions I prefer to use the hmcustomtcl file to automatically create the menu when Hyperworks X is launched

image

Find more posts tagged with

Sort by:
1 - 4 of 41

    Nice to meet you.

    By setting up a Preferenence file (mvw file), you can create a menu like the one shown below.
    Is this not what you are looking for?

    Thank you in advance.

    image

    image

    Nice to meet you.

    By setting up a Preferenence file (mvw file), you can create a menu like the one shown below.
    Is this not what you are looking for?

    Thank you in advance.

    image

    image

    @Kiyoshi Tsujimoto  Thank you for the Response.
    But I am looking for a different approach.
    In classic HyperMesh window, we use tcl/tk commands to create a dropdown menu..
    Below is a small example that I used to create a menu with 3 Options

    set menuName "Custom_Menu" set topMenu [. cget -menu]  #destroy custom menu catch {$topMenu delete [$topMenu index $menuName]} catch {destroy $topMenu.myMenu}  #Create the pull down menu menu $topMenu.myMenu -tearoff 0 $topMenu insert 20 cascade -label $menuName -menu $topMenu.myMenu $topMenu.myMenu add command -label "Option1" -command "puts Option1" -underline 0 $topMenu.myMenu add command -label "Option2" -command "puts Option2" -underline 0 $topMenu.myMenu add command -label "Option3" -command "puts Option3" -underline 0

    In a similar way , for Hyperworks X version, I would like to create a menu and remove the menu by only using TCL/TK commands and not by extensions or preferences files.

    I found the following that will at least help you get started:

    proc ::int_Menu::Main { } { 	variable str_scriptpath; 	if {[::HM_Framework::RunningUnityFramework]} { 		set str1 [hm_info -appinfo ALTAIR_HOME] 		set pyexe [file join $str1 ".." "common" "python" "python3.5" "win64" "python.exe"] 		 		set str_menuName "Menu Name" 		# puts $str_menuName 		::int_Menu::createandloadxml $str_menuName 	} } proc ::int_Menu::createandloadxml {str_menuName } { 		variable str_scriptpath;  		set csv "int_Menu.csv" 		set filename [file join $str_scriptpath "$csv"] 		set xmlfile "int_Menu.xml" 		 		 		set str1 [hm_info -appinfo ALTAIR_HOME] 		set strOS [string tolower $::tcl_platform(os)];  		if {[string first "win" $strOS]!= -1} { 			set xmlfilepath [pwd] 			set pyexe [file join [file dirname $str1] "common" "python" "python3.8" "win64" "python.exe"] 			puts "pyexe - $pyexe" 		} else {             set xmlfilepath $str_scriptpath             set pyexe [file join [file dirname $str1] "common" "python" "python3.8" "linux64" "bin" "python"]  		} 		set c [catch {exec $pyexe [file join $str_scriptpath read_tool_csv.py] $xmlfilepath $filename $xmlfile $str_menuName}] 		# exec $pyexe [file join $str_scriptpath read_tool_csv.py] $xmlfilepath $filename $xmlfile $str_menuName 		 		set strname [join [list "HMX_" [regsub {[-]} $str_menuName ""] "MenuPage"] ""] 		if {$c == 0} { 			::hwf::ribbonpage remove $strname 			::hwf::ribbonpage add [file join $xmlfilepath $xmlfile] 			puts "Done loading $str_menuName" 		} else { 			puts "some error while loading custom dropdown menus" 		} }

    Hello Ben,

    I tried the following API

    ::hwf::ribbonpage add

    This api doesnot change anything in the GUI.

    But the method of using the extension works for me except for 1 case.

    Do you have any api to update the ribbon.xml File??

    I could understand that we should load "extension.xml" and "Ribbon.xml" in the folder before loading hyperworks.

    But after opening Hyperworks, do you have any option to reload the updated Ribbon.xml file rather than relaunching Hyperworks?