MEL - Maya UI Building


#281

I have been trying to create a python maya UI with a file browse directory button… is there a preferred command to do this?

perhaps textFieldButtonGrp()?
or attrNavigationControlGrp()?
or something else?


#282

Anybody knows how to get the shader icon image from hypershade or attribute editor???

Or is there any way to get a snap shot of it???

We already know we could get some image from view port using playblast command

but this is beyond it.

Please help, or give any fresh idea to get there…


#283

I think the “saveSwatchesCmd” in the devkit does what you want. It creates a swatchDisplayPort and then saves an image of it. This might only work in Maya 2011 though…


#284

Is it the only way???

My maya version is 2009, you know…

(if this is just for personal use, I could upgrade to 2011, but it’s not…)

Thanks for your reply though,

this information will help me some day in the future :slight_smile:


#285

I tried to put layoutDialog window to desired position but only to fail.

I think layoutDialog has very limited options to control…

For example, in order to control the size of it, I had to use the ‘formLayout size flag’…

About the position however, I’m still not able to deal with it.

Help me guys, please!!!

Ps. the reason why I try to control the position is, it’s because it appears in different position in Maya 2011 compare to version 2009.


#286

just a note for Mac users that I just made an OS X Service to pass selected text to Maya, in any Cocoa based text editor (BBEdit, TextEdit, Textwrangler, Coda, etc).

http://polygonspixelsandpaint.tumblr.com/post/3226414038

Requires OS X 10.6 and above


#287

I have a lot of issues with scripts that wont work or display properly in 2011. I think most of the code was rewritten for 2011. If some one from AutoDesk could shine in with info as to what was rewritten or how to fix or work around the issues would be great. As for your problem i was not able to find the solution ether.


#288

layoutDialog probably works like the other dialogs promptDialog and confirmDialog: you can’t make it appear at a certain position. It always pops up in the middle of the top Maya window.

And the size thing is just normal. Istn’t it described that way in the docs already? :smiley: you are doing it right!

I have no experience with 2011 so far. Alas!


#289

Thank you for your reply nottoshabi, ewerybody~:)


#290

Hey guys,

I got one Normalized Normal Vector(Average) << 0.47548, 0.80906, -0.345457 >> using polyNormalPerVertex command.

I want rotation values from above to match an object’s rotation.

Someone told me I could do it using acos, and asin after projecting on a plane, but I don’t understand what it means.

Could anyone expain this specifically? (of course, an example will help a lot!!

For your information, I’m really bad at math)

Or, is any other ideas to accomplish what I want??

Ps. sorry for posting that has nothing to do with UI thing, but I post this here because I see some guys very experienced here, and I hope they will see this article.


#291

Ps. sorry for posting that has nothing to do with UI thing, but I post this here because I see some guys very experienced here, and I hope they will see this article.
Thats no excuse for misusing the forum. Open a thread. Thats what its for!


#292

You’re right, sorry for the mess :slight_smile:


#293

edit: remove post 'cause wrong section…sorry


#294

I want to add a tabLayout to my window to add more functions to my script. Seems simple enough, but I just can’t get it to work properly!
Been trying to figure it out for too long and rewrtiting it. Started from scratch a bunch of times but I just can’t seem to get it right so hopefully there’s someone who could help me out here?!


     if (`window -q -ex alignWin`)
          {
          deleteUI alignWin;
          }
  
      window -w 230 -h 60 -t "Dag's Align UI" alignWin;
  
      string $masterForm = `formLayout`;
      string $mainCol = `columnLayout  -adj 1`;
  
      setParent $masterForm;
  
      string $mainForm = `formLayout`;
      setParent $masterForm;
  
  
  
  
      rowLayout    -numberOfColumns 3
                  row2;
      setParent $mainCol;
      
  
  
  
  
  
  
  
  separator -h 10 -st none;
  
  $avg = `checkBoxGrp
                     -cal 1 center
                     -l "Average"
                     -v1 0
                     -on1 ""
                     -of1 "" 
                     `;    
                     
                     
  separator -h 10 -st none;
  setParent row2;
  
  
  
  setParent $mainCol;                
  
  setParent $mainForm;
  
  
  
  
  
  
  
  string $btn1 = `button    -l ("X") 
                  -c ""`;
  
  string $btn2 = `button    -l ("Y")
                  -c ""`;
                  
  string $btn3 = `button    -l ("Z")
                  -c ""`;
  
  string $btn4 = `button    -l ("-X")
                  -c ""`;
                  
  string $btn5 = `button    -l ("-Y")
                  -c ""`;
                  
  string $btn6 = `button    -l ("-Z")
                  -c ""`;
  
  string $btn7 = `button    -l ("planarize")
                  -c ""`;
                  
  
  int $rowHeight = 33;
  int $border = 5;
  
  formLayout -e
      
          -af $mainCol "top" 0
  
          -af $mainCol "left" 0
          -af $mainCol "right" 0
      
          -ac $mainForm "top" 0 $mainCol
          -af $mainForm "bottom" 0  
          -af $mainForm "left" 0
          -af $mainForm "right" 0
          
          $masterForm;
  
          
  formLayout -e
  
  //Row 1
  
          -af $btn1 "top" 0
          -ap $btn1 "bottom" 0 $rowHeight
          -af $btn1 "left" 0
          -ap $btn1 "right" 0 33
          
          -af $btn2 "top" 0
          -ap $btn2 "bottom" 0 $rowHeight
          -ap $btn2 "left" 0 33
          -ap $btn2 "right" 0 66
          
          -af $btn3 "top" 0
          -ap $btn3 "bottom" 0 $rowHeight
          -ap $btn3 "left" 0 66
          -af $btn3 "right" 0
  
  
  //Row 2
          -ac $btn4 "top" 0 $btn2
          -ap $btn4 "bottom" 0 ($rowHeight*2)
          -af $btn4 "left" 0
          -ap $btn4 "right" 0 33
  
          -ac $btn5 "top" 0 $btn2
          -ap $btn5 "bottom" 0 ($rowHeight*2)
          -ap $btn5 "left" 0 33
          -ap $btn5 "right" 0 66
  
          -ac $btn6 "top" 0 $btn2
          -ap $btn6 "bottom" 0 ($rowHeight*2)
          -ap $btn6 "left" 0 66
          -af $btn6 "right" 0 
  
  
  //Row 3
          -ap $btn7 "top" 0 70
          -af $btn7 "bottom" 0
          -af $btn7 "left" 0
          -af $btn7 "right" 0
          $mainForm;
  
  window -e -w 585 -h 175 alignWin;
      showWindow alignWin;
  

#295

what’s the problem exactly Geuse? adding a tabLayout is really no different to adding any other layout…?
:nathaN

if (`window -q -ex alignWin`)
	deleteUI alignWin;
window -w 230 -h 60 -t "Dag's Align UI" alignWin;
  
string $masterForm = `formLayout`;
	// I dunno where you want this... lets just put it on main layout above tabs?
	string $avg = `checkBoxGrp -cal 1 center -l "Average" -v1 0`;
	string $tab = `tabLayout`;
	// now we have a parent tabLayout, add it's child layouts (one for each tab)
		string $alignForm = `formLayout`;
			string $btn1 = `button	-l ("X") -c ""`;
			string $btn2 = `button	-l ("Y") -c ""`;
			string $btn3 = `button	-l ("Z") -c ""`;
			string $btn4 = `button	-l ("-X") -c ""`;
			string $btn5 = `button	-l ("-Y") -c ""`;
			string $btn6 = `button	-l ("-Z") -c ""`;
			string $btn7 = `button	-l ("planarize") -c ""`;
		setParent ..;	// close the align formLayout
		string $helpForm = `formLayout`;
			string $helpField = `scrollField -text "some help text.. or whatever..."`;
		setParent ..;    // close the help formLayout
	setParent ..;    // close the tabLayout
setParent ..;	// close the main formLayout
// set the tab names:
tabLayout -e -tli 1 "Alignment" -tli 2 "Help" $tab;
// now all our UI is created, set our form attachments:
int $rowHeight = 33;
int $border = 5;
// attach the tab layout to the whole window form:
formLayout -e
	-af $avg "top" $border
	-af $avg "left" $border
	-af $avg "right" $border
	-an $avg "bottom"
	-ac $tab "top" $border $avg
	-af $tab "left" 0
	-af $tab "right" 0
	-af $tab "bottom" 0  
	$masterForm;
// sort out the align layout:
formLayout -e
//Row 1
	-af $btn1 "top" 0
	-ap $btn1 "bottom" 0 $rowHeight
	-af $btn1 "left" 0
	-ap $btn1 "right" 0 33
	-af $btn2 "top" 0
	-ap $btn2 "bottom" 0 $rowHeight
	-ap $btn2 "left" 0 33
	-ap $btn2 "right" 0 66
	-af $btn3 "top" 0
	-ap $btn3 "bottom" 0 $rowHeight
	-ap $btn3 "left" 0 66
	-af $btn3 "right" 0
//Row 2
	-ac $btn4 "top" 0 $btn2
	-ap $btn4 "bottom" 0 ($rowHeight*2)
	-af $btn4 "left" 0
	-ap $btn4 "right" 0 33
	-ac $btn5 "top" 0 $btn2
	-ap $btn5 "bottom" 0 ($rowHeight*2)
	-ap $btn5 "left" 0 33
	-ap $btn5 "right" 0 66
	-ac $btn6 "top" 0 $btn2
	-ap $btn6 "bottom" 0 ($rowHeight*2)
	-ap $btn6 "left" 0 66
	-af $btn6 "right" 0 
//Row 3
	-ap $btn7 "top" 0 70
	-af $btn7 "bottom" 0
	-af $btn7 "left" 0
	-af $btn7 "right" 0
	$alignForm;
// finally sort out the help layout
formLayout -e
	-af $helpField "top" 0
	-af $helpField "left" 0
	-af $helpField "right" 0
	-af $helpField "bottom" 0  
	$helpForm;
window -e -w 585 -h 175 alignWin;
showWindow alignWin;



#296

Aaaa. SO Fu**ing sweet of you!!
Thank You!

Yes I just couldn’t understand it. Shouldn’t be that much of a problem, but couldn’t get it right. I’m gonna look through the code and see what I should’ve done.

thank you!

Oh, and what would be the correct way of altering the layouts to put the checkbox in the same window as the buttons?
I don’t understand it fully and still can’t get it to look correct =/


#297

well. I fiddled with it a bit more and got it almost as I wanted, but somehow I managed to put the buttons and textbox in opposite tabs =/ and I can’t figure out where it went so wrong and this was the only way to be clear of any errors! =/

much obliged…

PS. Is there a quick way of making the average checkbox stretch horisontally with the window?

if (`window -q -ex alignWin`)     	{
      	deleteUI alignWin;
      	}
       window -w 230 -h 60 -t "Dag's Align UI" alignWin;
       string $Form = `formLayout`;
      string $tab = `tabLayout`;
         string $helpForm = `formLayout`;
      string $helpField = `scrollField -text "some help text.. or whatever"`;
      setParent $tab;
         string $masterForm = `formLayout`;
      string $mainCol = `columnLayout  -adj 1`;
      setParent..;
       string $mainForm = `formLayout`;
      rowLayout	-numberOfColumns 3
  				                row2;
      setParent $mainCol;
  	
       separator -h 10 -st none;
   $avg = `checkBoxGrp
                     -cal 1 center
                     -l "Average"
                     -v1 0
                     -on1 ""
                     -of1 "" 
                     `;	
  				   
  separator -h 10 -st none;
   setParent $mainForm;
         string $btn1 = `button    -l ("X") 
                  -c "dag_alignMain \"+\" \"x\""`;
   string $btn2 = `button    -l ("Y")
                  -c "dag_alignMain \"+\" \"y\""`;
  	            
  string $btn3 = `button    -l ("Z")
                  -c "dag_alignMain \"+\" \"z\""`;
   string $btn4 = `button    -l ("-X")
                  -c "dag_alignMain \"-\" \"x\""`;
                  
  string $btn5 = `button    -l ("-Y")
                  -c "dag_alignMain \"-\" \"y\""`;
                  
  string $btn6 = `button    -l ("-Z")
                  -c "dag_alignMain \"-\" \"z\""`;
   string $btn7 = `button    -l ("planarize")
                  -c ""`;
                  
     tabLayout -e -tli 1 "Alignment" -tli 2 "Help" $tab;
   int $rowHeight = 33;
  int $border = 5;
     formLayout -e
  	-af $tab "top" $border
  	-af $tab "left" 0
  	-af $tab "right" 0
  	-af $tab "bottom" 0  
  	$Form;
      formLayout -e
  	
      	-af $mainCol "top" 0
       	-af $mainCol "left" 0
      	-af $mainCol "right" 0
  	
      	-ac $mainForm "top" 0 $mainCol
      	-af $mainForm "bottom" 0  
      	-af $mainForm "left" 0
      	-af $mainForm "right" 0
  		
  		$masterForm;
   		
  formLayout -e
   //Row 1
       	-af $btn1 "top" 0
      	-ap $btn1 "bottom" 0 $rowHeight
      	-af $btn1 "left" 0
      	-ap $btn1 "right" 0 33
  		
      	-af $btn2 "top" 0
      	-ap $btn2 "bottom" 0 $rowHeight
      	-ap $btn2 "left" 0 33
      	-ap $btn2 "right" 0 66
  		
  		-af $btn3 "top" 0
      	-ap $btn3 "bottom" 0 $rowHeight
      	-ap $btn3 "left" 0 66
      	-af $btn3 "right" 0
    //Row 2
      	-ac $btn4 "top" 0 $btn2
      	-ap $btn4 "bottom" 0 ($rowHeight*2)
      	-af $btn4 "left" 0
      	-ap $btn4 "right" 0 33
       	-ac $btn5 "top" 0 $btn2
      	-ap $btn5 "bottom" 0 ($rowHeight*2)
      	-ap $btn5 "left" 0 33
      	-ap $btn5 "right" 0 66
       	-ac $btn6 "top" 0 $btn2
      	-ap $btn6 "bottom" 0 ($rowHeight*2)
      	-ap $btn6 "left" 0 66
  		-af $btn6 "right" 0 
    //Row 3
      	-ap $btn7 "top" 0 70
      	-af $btn7 "bottom" 0
      	-af $btn7 "left" 0
      	-af $btn7 "right" 0
          $mainForm;
     formLayout -e
  	-af $helpField "top" 0
  	-af $helpField "left" 0
  	-af $helpField "right" 0
  	-af $helpField "bottom" 0  
  	$helpForm;
      window -e -w 585 -h 175 alignWin;
      showWindow alignWin;
  

#298

Hi,
I would like to alter the maya UI in a way like the attached picture:
In the red circle, you can see different editors in a tabbed manner. Before I dig deeper to find out what UI-scripts have to be altered and how, I wanted to ask if it is possible to do (and where to begin).
An easier way could be to add some buttons on the right corner like they did it with the grapheditor (green circle). Here I only had success to alter the function of an existing button of the grapheditor (now calls hypershade instead of dopesheet) but i was unable to add another button nor all buttons to the hypershad window.
Any help appreciated
Marco


#299

I’d doubt that something like that would be possible: But I actually don’t know about Maya 2011s Qt interface so far.

Traditionally the Main view has from 1 to 4 embedded panels. So the panel controls appear at each panels top.

At the picture you have the top panels and the bottom one separated by the tabs… but Wait! Couldn’t you create a custom panel that has a tabLayout and further panels in the single tabs?.. but that would be a panel in a panel… I’don’t know if that works. You’d have a panel control menu for your custom tab panel too!

Anyway: Why not layouts like that? Layouts are not tabs but you’d have them at the left sidePanel.


#300

Gday all.

Quick question regarding UI. I’m writing a script at the moment and I want to add a file browser in the UI, like a texture file node has, where you browse for the image. The way I thought you would go about it is by using a textFieldButtonGrp and then have the button open a fileDialog. However I’m unsure on how to get the file that I select in the fileDialog to appear in the text Field after I click ok.

Any help would be greatly appreciated. Cheers Jake