Ignore the graph editor when using the Scriptjob

Ignore the graph editor when using the Scriptjob

dg3duy
Collaborator Collaborator
488 Views
3 Replies
Message 1 of 4

Ignore the graph editor when using the Scriptjob

dg3duy
Collaborator
Collaborator

This command line does the centering of all panels, I do not want it to be applied in graph editor.

fitPanel -selectedNoChildren;


I want to use it only in perspective and Front Side etc. cameras.

I don't want to use it in graph editor because it updates on each selection the centering. any idea how to override the command in graph editor?

 

 

 

global proc framesel1()
	{
fitPanel -selectedNoChildren;
	}
	
	global proc framesel2()
	{
select -cl;
Undo;
	}
int $jobId1 = `scriptJob -ct "SomethingSelected" framesel1`;
int $jobId2 = `scriptJob -e "SelectionChanged" framesel2`;

 

 

Snap.gif

0 Likes
Accepted solutions (1)
489 Views
3 Replies
Replies (3)
Message 2 of 4

dg3duy
Collaborator
Collaborator

@Kahylan 
Any lifeline for this, any way that can be used?

0 Likes
Message 3 of 4

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

It's quite easy actually, all you have to do it query the paneltype and check if it is in focus.

If you just want to exclude the grapheditor:

global proc framesel1()
	{
string $graphPanels[] = `getPanel -typ "graphEditorPanel"`;
string $focusPanel = `getPanel -wf`;
if (stringArrayContains($focusPanel, $graphPanels)==0){
    fitPanel -selectedNoChildren;
}


	}
	
	global proc framesel2()
	{

select -cl;
Undo;
	}
int $jobId1 = `scriptJob -ct "SomethingSelected" framesel1`;
int $jobId2 = `scriptJob -e "SelectionChanged" framesel2`;

 

If you want to exclude all panels except the viewport:

global proc framesel1()
	{
string $modPanels[] = `getPanel -typ "modelPanel"`;
string $focusPanel = `getPanel -wf`;
if (stringArrayContains($focusPanel, $modPanels)==1){
    fitPanel -selectedNoChildren;
}


	}
	
	global proc framesel2()
	{

select -cl;
Undo;
	}
int $jobId1 = `scriptJob -ct "SomethingSelected" framesel1`;
int $jobId2 = `scriptJob -e "SelectionChanged" framesel2`;

 

Btw, jobId2 seems to be stuck in an infinite loop until nothing is selected...

 

I hope it helps!

Message 4 of 4

dg3duy
Collaborator
Collaborator

@Kahylan 

Thank you so much for the lifesaver! I can't thank you enough, you are a hero.

Of the 2 examples, the situation is very curious.
1.In the first example the grapheditor doesn't ignore it, it keeps doing autofit.

2.The second example works perfect and I don't have any infinite loop or anything extra, I'm using maya2020.
Anyway the second example is working perfectly and is what I needed.

 

string $graphEditors[] = `getPanel -scriptType graphEditor`;

to the first script just change this line like this and it works perfect

 

0 Likes