I want to know how to switch the function shortcut key inside the outliner to toggle.

I want to know how to switch the function shortcut key inside the outliner to toggle.

tjdrbrla
Advocate Advocate
496 Views
5 Replies
Message 1 of 6

I want to know how to switch the function shortcut key inside the outliner to toggle.

tjdrbrla
Advocate
Advocate

There are four registered shortcuts shown in the picture (E, R, Q, W).
Can E and R be one shortcut among the functions of the shortcut?
Also, can we make Q and W into one shortcut? For example, I want to use the Outliner (All Items, All Selected Items) Expand and Collapse functions at the same time as one shortcut. And like before, only with the outliner! I want the shortcut to work. Is Custom shortcut possible?

 

tjdrbrla_0-1676187859036.png

 

{
	string $panel = `getCurrentOutlinerPanel`;
	if ("" != $panel) {
		int $bool = `outlinerEditor -q -showDagOnly $panel`;
		outlinerEditor -e -showDagOnly (!$bool) $panel;
	}
}

The code above is a command that allows you to switch the DAG Objects Only function, which only works with the Outliner, and I hope this will help.

0 Likes
Accepted solutions (1)
497 Views
5 Replies
Replies (5)
Message 2 of 6

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

It's a bit hacky, since there isn't really a way to query the last expand/collapse that happend, so I had to introduce 2 optionVars (Variables that are stored in prefs) to keep track of that. But this works:

 

Expand All:

 

{
    int $eai =1;
    int $t = `optionVar -ex "outlinerExpandToggle"`;

	if ($t == 0){
	optionVar -iv "outlinerExpandToggle" 1;
	}
	else{
	$eai = `optionVar -q "outlinerExpandToggle"`;
	}
	string $panel = `getCurrentOutlinerPanel`;
	if ("" != $panel) {
		outlinerEditor -e -eai $eai $panel;
	}
	if ($eai == 1){
	    optionVar -iv "outlinerExpandToggle" 0;
	    
	}
	else{
	    optionVar -iv "outlinerExpandToggle" 1;
	}
}

 

 

Expand Selection:

 

{
    int $eas =1;
    int $t = `optionVar -ex "outlinerSelectExpandToggle"`;

	if ($t == 0){
	optionVar -iv "outlinerSelectExpandToggle" 1;
	}
	else{
	$eas = `optionVar -q "outlinerSelectExpandToggle"`;
	}
	string $panel = `getCurrentOutlinerPanel`;
	if ("" != $panel) {
		outlinerEditor -e -eas $eas $panel;
	}
	if ($eas == 1){
	    optionVar -iv "outlinerSelectExpandToggle" 0;
	    
	}
	else{
	    optionVar -iv "outlinerSelectExpandToggle" 1;
	}
}

 

 

I'm not quite sure if there is a more elegant way of doing this.

 

I hope it helps!

0 Likes
Message 3 of 6

tjdrbrla
Advocate
Advocate

Thank you, both scripts performed the commands I wanted!

Can't custom commands allow shortcut registration only in the editor?
The normal command is because the hot keys that you set are full, so you have to press several times. This is impossible, right?

 

 

If you can register only in the Outliner Editor as shown in the picture, I think you can register Shortcut more efficiently.

 

Even if this is impossible, I am very grateful for the command you gave me.

tjdrbrla_0-1676377193262.png

 

0 Likes
Message 4 of 6

tjdrbrla
Advocate
Advocate
If you feel that my request is impossible, could you change it so that it can be executed in Viewport, not just in the outliner? I'm sorry for bothering you. I thought I could register for the outliner.
0 Likes
Message 5 of 6

Kahylan
Advisor
Advisor

I don't think it is possible to attach a custom script to a specific editor. But that also doesn't matter. The view you are showing in the Screenshot is simply a filtered view that shows all the hotkeys you set that are assosiated with the outliner by maya, but they just run a script like a custom script does as well. If you set the hotkey of the custom script to a key that isn't taken it should run as efficiently as scripts that are assosiated with the outliner.

 

One key difference is, that you will sometimes have to hit the hotkey twice, since the expand/collapse is defined by a dummyvariable that has nothing to do with the state of the outliner and just switches between expand/collapse based on a number. This can't be changed since the outliner doesn't have anything like an "expanded state" that can be querried, so that is simply impossible. It can sometimes happen that you have to hit the button twice if you expanded/collapsed in a different way.

Message 6 of 6

tjdrbrla
Advocate
Advocate
Thank you for your reply.
Maya's Shortcut is difficult.
But thankfully, I'll use it well. Thank you.