🎉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

Create shortcut for 'Make Current' in the model tree.

User: "Blake Berk"
Altair Community Member
Updated by Blake Berk

Hi,

I am looking to create a keyboard quick-key for Make Current in HyperMesh. I can't figure out what the proper command would be to modify the keyboard preferences.

I would like to be on the component, press a key (or CTRL+key) and it will become the current component.

Thanks for the help!

Find more posts tagged with

Sort by:
1 - 8 of 81
    User: "tinh"
    Altair Community Member
    Updated by tinh
    Hi Keyboard preferences are applicable to hm graphic window (this is not created from Tk GUI) Model browser is a Tk GUI (a TreeCtrl widget) To add shortcut key when selecting a component on the browser, we need to bind a tcl script to keypress event of the TreeCtrl. Within this script, you have to specify selected component name. Could you make this script? I will check how we can do that later (because I don't have hypermesh at home!)
    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    Agree with @tinh , that's the key of script.

    User: "Blake Berk"
    Altair Community Member
    OP
    Updated by Blake Berk

    Hi Keyboard preferences are applicable to hm graphic window (this is not created from Tk GUI) Model browser is a Tk GUI (a TreeCtrl widget) To add shortcut key when selecting a component on the browser, we need to bind a tcl script to keypress event of the TreeCtrl. Within this script, you have to specify selected component name. Could you make this script? I will check how we can do that later (because I don't have hypermesh at home!)

    Hi tinh,

    Thanks for the help. I have been searching the directories and I found '\hm\scripts\createtreectrl.tcl', which has a couple procedures that point to the default quick-keys (CTRL+D, Q, etc.). However, I tried modifying 'Q' to also work for another letter and it did not work. I have yet to find an ASCII script that references these key commands and makes it possible to edit successfully. 

    Any more focused script changes to allow it to control the actual application?

    Thanks!

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi,

    we can bind a script to browser tree but it's removed when the tree disappeared (like when change a browser)

    so I bind a script to the class... pls try attached file.

    Tested on HM2019

    #click on a browser to focus it (need for binding script) #move mouse to a component on browser #press 'c' key to make current the comp #it works with load collectors and includes! #and other browsers  proc ::createMakeCurrentShortcutKey {Key args} { 	if {$Key == "->"} { 		lassign $args tree x y 		if {[regexp {^(\.model)|(\.fepre_model).+(\.content)|(\.include)|(\.comp)|(\.assem).+__treectrl$} $tree]} { 			if {[catch { 				set item [dict get [$tree identify $x $y] item] 			}]} return 			set name [lindex [$tree item text $item] 0] 			if {$name == ""} {set name [lindex [$tree item text $item] 2]} 			set item_elems [$tree item style elements $item 0] 			set item_images {} 			foreach elem $item_elems { 				catch {lappend item_images [$tree item element cget $item 0 $elem -image]} 			} 			set parent [$tree item parent $item] 			set parent_images {} 			if {$parent} { 				set parent_elems [$tree item style elements $parent 0] 				foreach elem $parent_elems { 					catch {lappend parent_images [$tree item element cget $parent 0 $elem -image]} 				} 			} 			set entity_type "" 			switch -glob -- [join $parent_images] { 				folderComponents* {set entity_type comps} 				folderLoadCollectors {set entity_type loadcols} 				folderGeometry* - folderAssemblies* { 					if {[string match entityGeometry* $item_images]} { 						set entity_type comps 					} 				} 				folderIncludes* {set entity_type include} 				"" { 					switch -glob -- [join $item_images] { 						entityGeometry* {set entity_type comps} 						entityIncludes* {set entity_type include} 					} 				} 			} 			if {$entity_type == "include"} { 				*setcurrentinclude [expr {$name eq "Master Model"?0:[hm_getincludeid $name]}] 			} elseif {$entity_type in {comps loadcols}} { 				*currentcollector $entity_type $name 			} 		} 		return 	} 	bind TreeCtrl <Key-$Key> [list ::createMakeCurrentShortcutKey -> %W %x %y] } ::createMakeCurrentShortcutKey c ::createMakeCurrentShortcutKey C
    User: "Blake Berk"
    Altair Community Member
    OP
    Updated by Blake Berk

    Hi,

    we can bind a script to browser tree but it's removed when the tree disappeared (like when change a browser)

    so I bind a script to the class... pls try attached file.

    Tested on HM2019

    #click on a browser to focus it (need for binding script) #move mouse to a component on browser #press 'c' key to make current the comp #it works with load collectors and includes! #and other browsers  proc ::createMakeCurrentShortcutKey {Key args} { 	if {$Key == "->"} { 		lassign $args tree x y 		if {[regexp {^(\.model)|(\.fepre_model).+(\.content)|(\.include)|(\.comp)|(\.assem).+__treectrl$} $tree]} { 			if {[catch { 				set item [dict get [$tree identify $x $y] item] 			}]} return 			set name [lindex [$tree item text $item] 0] 			if {$name == ""} {set name [lindex [$tree item text $item] 2]} 			set item_elems [$tree item style elements $item 0] 			set item_images {} 			foreach elem $item_elems { 				catch {lappend item_images [$tree item element cget $item 0 $elem -image]} 			} 			set parent [$tree item parent $item] 			set parent_images {} 			if {$parent} { 				set parent_elems [$tree item style elements $parent 0] 				foreach elem $parent_elems { 					catch {lappend parent_images [$tree item element cget $parent 0 $elem -image]} 				} 			} 			set entity_type "" 			switch -glob -- [join $parent_images] { 				folderComponents* {set entity_type comps} 				folderLoadCollectors {set entity_type loadcols} 				folderGeometry* - folderAssemblies* { 					if {[string match entityGeometry* $item_images]} { 						set entity_type comps 					} 				} 				folderIncludes* {set entity_type include} 				"" { 					switch -glob -- [join $item_images] { 						entityGeometry* {set entity_type comps} 						entityIncludes* {set entity_type include} 					} 				} 			} 			if {$entity_type == "include"} { 				*setcurrentinclude [expr {$name eq "Master Model"?0:[hm_getincludeid $name]}] 			} elseif {$entity_type in {comps loadcols}} { 				*currentcollector $entity_type $name 			} 		} 		return 	} 	bind TreeCtrl <Key-$Key> [list ::createMakeCurrentShortcutKey -> %W %x %y] } ::createMakeCurrentShortcutKey c ::createMakeCurrentShortcutKey C

    Thank you so much for the support! Where should I put the attached file/proc to link it to HM2019?

    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    Hi @tinh , just tried your script. It works well! In my below test, the component 32 will become "Current". That operation needs the mouse focus on component.

    Do you see the component 37? When I used arrow keys to move around tree, 37 is component "focus" by keyboard. So if your script is binding on "keyboard" focus it's better; because we not need mouse focus.

    Thanks

    image

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Mr @Q.Nguyen-Dai 

    To make it sense with arrow key, we can get the focus item as selected item

    I rarely use arrow keys. And there are several scenarios depend on each user so they can customize the script them self.

    Below is a scenario the script prefers 'arrow keys' as your mention, but it accepts 'mouse over' also!

    if you want to ignore 'mouse over', pls uncomment the line #set moverItem ""

     

     

    #use arrow keys to focus item that will be made current #but if selected item is already current, mouse-over item will be considered!  proc ::createMakeCurrentShortcutKey {Key args} { 	if {$Key == "->"} { 		lassign $args tree x y 		if {[regexp {^(\.model)|(\.fepre_model).+(\.content)|(\.include)|(\.comp)|(\.assem).+__treectrl$} $tree]} { 			lassign [$tree selection get] selectedItem 			set moverItem "" 			if {[catch { 				set moverItem [dict get [$tree identify $x $y] item] 			}]} {} 			#we prefer selected item than item at mouse, if we want to ignore mouse over item, uncomment: 			#set moverItem "" 			if {$selectedItem != ""} { 				set item $selectedItem 			} elseif {$moverItem != ""} { 				set item $moverItem 			} else return 			while 1 { 				set name [lindex [$tree item text $item] 0] 				if {$name == ""} {set name [lindex [$tree item text $item] 2]} 				set item_elems [$tree item style elements $item 0] 				set item_images {} 				foreach elem $item_elems { 					catch {lappend item_images [$tree item element cget $item 0 $elem -image]} 				} 				set parent [$tree item parent $item] 				set parent_images {} 				if {$parent} { 					set parent_elems [$tree item style elements $parent 0] 					foreach elem $parent_elems { 						catch {lappend parent_images [$tree item element cget $parent 0 $elem -image]} 					} 				} 				set entity_type "" 				switch -glob -- [join $parent_images] { 					folderComponents* {set entity_type comps} 					folderLoadCollectors {set entity_type loadcols} 					folderGeometry* - folderAssemblies* { 						if {[string match entityGeometry* $item_images]} { 							set entity_type comps 						} 					} 					folderIncludes* {set entity_type include} 					"" { 						switch -glob -- [join $item_images] { 							entityGeometry* {set entity_type comps} 							entityIncludes* {set entity_type include} 						} 					} 				} 				if {$entity_type == "include"} { 					*setcurrentinclude [expr {$name eq "Master Model"?0:[hm_getincludeid $name]}] 				} elseif {$entity_type in {comps loadcols}} { 					set entity_id [hm_getentityvalue $entity_type $name id 0 -byname] 					if {$entity_id == [hm_info currentcollector $entity_type]} { 						#if selected is current, we may want to make current item at mouse: 						if {$item eq $selectedItem && $moverItem ne "" && $selectedItem ne $moverItem} { 							$tree selection clear 							$tree selection add $moverItem 							set item $moverItem 							set selectedItem $moverItem 							continue 						} else break 					} 					*currentcollector $entity_type $name 				} 				break 			} 		} 		return 	} 	bind TreeCtrl <Key-$Key> [list ::createMakeCurrentShortcutKey -> %W %x %y] } ::createMakeCurrentShortcutKey c ::createMakeCurrentShortcutKey C 
    User: "QuyNguyenDai"
    Altair Community Member
    Updated by QuyNguyenDai

    Hi Mr @Q.Nguyen-Dai 

    To make it sense with arrow key, we can get the focus item as selected item

    I rarely use arrow keys. And there are several scenarios depend on each user so they can customize the script them self.

    Below is a scenario the script prefers 'arrow keys' as your mention, but it accepts 'mouse over' also!

    if you want to ignore 'mouse over', pls uncomment the line #set moverItem ""

     

     

    #use arrow keys to focus item that will be made current #but if selected item is already current, mouse-over item will be considered!  proc ::createMakeCurrentShortcutKey {Key args} { 	if {$Key == "->"} { 		lassign $args tree x y 		if {[regexp {^(\.model)|(\.fepre_model).+(\.content)|(\.include)|(\.comp)|(\.assem).+__treectrl$} $tree]} { 			lassign [$tree selection get] selectedItem 			set moverItem "" 			if {[catch { 				set moverItem [dict get [$tree identify $x $y] item] 			}]} {} 			#we prefer selected item than item at mouse, if we want to ignore mouse over item, uncomment: 			#set moverItem "" 			if {$selectedItem != ""} { 				set item $selectedItem 			} elseif {$moverItem != ""} { 				set item $moverItem 			} else return 			while 1 { 				set name [lindex [$tree item text $item] 0] 				if {$name == ""} {set name [lindex [$tree item text $item] 2]} 				set item_elems [$tree item style elements $item 0] 				set item_images {} 				foreach elem $item_elems { 					catch {lappend item_images [$tree item element cget $item 0 $elem -image]} 				} 				set parent [$tree item parent $item] 				set parent_images {} 				if {$parent} { 					set parent_elems [$tree item style elements $parent 0] 					foreach elem $parent_elems { 						catch {lappend parent_images [$tree item element cget $parent 0 $elem -image]} 					} 				} 				set entity_type "" 				switch -glob -- [join $parent_images] { 					folderComponents* {set entity_type comps} 					folderLoadCollectors {set entity_type loadcols} 					folderGeometry* - folderAssemblies* { 						if {[string match entityGeometry* $item_images]} { 							set entity_type comps 						} 					} 					folderIncludes* {set entity_type include} 					"" { 						switch -glob -- [join $item_images] { 							entityGeometry* {set entity_type comps} 							entityIncludes* {set entity_type include} 						} 					} 				} 				if {$entity_type == "include"} { 					*setcurrentinclude [expr {$name eq "Master Model"?0:[hm_getincludeid $name]}] 				} elseif {$entity_type in {comps loadcols}} { 					set entity_id [hm_getentityvalue $entity_type $name id 0 -byname] 					if {$entity_id == [hm_info currentcollector $entity_type]} { 						#if selected is current, we may want to make current item at mouse: 						if {$item eq $selectedItem && $moverItem ne "" && $selectedItem ne $moverItem} { 							$tree selection clear 							$tree selection add $moverItem 							set item $moverItem 							set selectedItem $moverItem 							continue 						} else break 					} 					*currentcollector $entity_type $name 				} 				break 			} 		} 		return 	} 	bind TreeCtrl <Key-$Key> [list ::createMakeCurrentShortcutKey -> %W %x %y] } ::createMakeCurrentShortcutKey c ::createMakeCurrentShortcutKey C 

    Thanks