Help with UV-manipulation

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 08 August 2012   #1
Help with UV-manipulation

Hi
I'm working on the textureWindowCreateToolbar.mel to create additional shortcut buttons in the standard UV texture editor. So far things have gone a lot better then expected, but now I've bumped into problems and need help.

What I wanna change compared to the default code is to remove one of the input fields (one is enough for me) and to add a lot of extra buttons. Now that part seems settled (I think) - although I'm unsure that the buttons are "hooked" to the input field correctly. Either way: the procedures I use to manipulate the UV's are based on the nudgeIt -MEL script. So I've basicly taken that way of writing and applying it on my own stuff. So far the code looks like this:

	/////////////////////////////
	// Functions and variables //
	/////////////////////////////
	
global float $manipAmt;
$manipAmt=0.1;

global proc UVmanip(float $manipAmt)
{
	print ("Manipulation value set to: "+$manipAmt+" UV units.");
}

global proc UVmanipulation(float $manipType, float $manipAmt)
{
	switch ($manipType){
	case "1":
	polyEditUV -u 0 -v $manipAmt; // Up
	break;
	
	case "2":
	polyEditUV -u ($manipAmt * -1) -v 0; // Left
	break;
	
	case "3":
	polyEditUV -u $manipAmt -v 0; // Right
	break;
	
	case "4":
	polyEditUV -u 0 -v ($manipAmt * -1); // Down
	break;	
	
	case "5":
	polyEditUV -a ($manipAmt * -1); // CW Rotation
	break;
	
	case "6":
	polyEditUV -a $manipAmt; // CCW Rotation
	break;
	
	case "7":
	polyEditUV -s ($manipAmt); // Scale up
	break;	
	
	case "8":
	polyEditUV -s ($manipAmt * -1);	// Scale down
	break;	
	
	case "9":
	polyEditUV -su ($manipAmt * 1);	// Scale U up
	break;	
	
	case "10":
	polyEditUV -su ($manipAmt * -1); // Scale U down
	break;	
	
	case "11":
	polyEditUV -sv ($manipAmt * 1);	 // Scale V up
	break;

	case "12":
	polyEditUV -sv ($manipAmt * -1); // Scale V down
	break;	
	}
}

	/////////////////////
	// UV Manip layout //
	/////////////////////
	setParent ..;

	//
	// Init hidden/shown option var
	//
	if (!`optionVar -exists "showStatusCopyPaste"`) {
		optionVar -intValue "showStatusCopyPaste" 1;
	}

	string $toggleCopyPasteCmd = "\"copyPasteLayout\", " +
								 "\"copyPasteCollapse\", " +
								 "\"\", " + 
								 "\"showStatusCopyPaste\")"; 

	//
	// Set up open/close bar
	//
	setUITemplate -pushTemplate TexWinBarTemplate;

	iconTextButton -vis true
		-parent $gUVTexEditToolBar
		-annotation (uiRes("m_textureWindowCreateToolBar.kShowHideCopyPasteIco  nsAnnot"))
		-i1 textureEditorOpenBar.png  
		-c ("textureWindowCreateToolBar_toggleIcons(-1," + $toggleCopyPasteCmd)
		copyPasteCollapse;

	setUITemplate -popTemplate;

	//
	// Set up icons
	//
	// copy/paste controls
	formLayout manipLayout;

	global string $uvEntryField;

	setUITemplate -pushTemplate TexWinFloatFieldTemplate;

    int $floatFieldWidth =  $iconSize * 2 + $horizGap;
	floatField 
		-precision 3
		-ed true
        -width $floatFieldWidth
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueTotransfor  mInUAnnot"))
		$uvEntryField;

	setUITemplate -popTemplate;
	
//	
// Klart för test och felsök
//
	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(1,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveUp;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(4,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveDown;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(2,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveLeft;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(3,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveRight;		
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(5,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipRotCW;	
		
	setUITemplate -popTemplate;
	
	
	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(6,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipRotCCW;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(7,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleUp;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(8,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleDown;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(9,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleUpU;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(10,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleDownU;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(11,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleUpV;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(12,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleDownV;		

	setUITemplate -popTemplate;

	
	formLayout -edit
	
		-attachForm     uvEntryField		"top"	$edgeMargins
		-attachForm	uvEntryField 		"left"	0 
		
		-attachControl 	manipRotCCW		"top" 	$edgeMargins
		-attachControl 	manipRotCCW		"left" 	uvEntryField
		-attachControl 	manipRotCW		"top" 	$edgeMargins
		-attachControl 	manipRotCW		"left" 	manipRotCCW
		
		-attachControl 	manipScaleUp 		"top" 	$edgeMargins
		-attachControl 	manipScaleUp 		"left" 	manipRotCW
		-attachControl 	manipScaleUpU 		"top" 	$edgeMargins
		-attachControl 	manipScaleUpU 		"left" 	manipScaleUp
		-attachControl 	manipScaleUpV 		"top" 	$edgeMargins
		-attachControl 	manipScaleUpV 		"left" 	manipScaleUpU
		
		-attachForm	manipMoveLeft		"left" 	0
		-attachControl 	manipMoveLeft		"top" 	uvEntryField
		-attachControl  manipMoveRight		"left" 	manipMoveLeft
		-attachControl  manipMoveRight		"top" 	uvEntryField
		-attachControl  manipMoveUp 		"left" 	manipMoveRight
		-attachControl  manipMoveUp 		"top" 	manipRotCCW
		-attachControl  manipMoveBottom		"left" 	manipMoveUp
		-attachControl  manipMoveBottom		"top" 	manipRotCW
		
		-attachControl  manipScaleDown		"left" 	manipMoveDown
		-attachControl  manipScaleDown		"top" 	manipScaleUp
		-attachControl  manipScaleDownU		"left" 	manipScaleDown
		-attachControl  manipScaleDownU		"top" 	manipScaleUpU
		-attachControl  manipScaleDownV		"left" 	manipScaleDownU
		-attachControl  manipScaleDownV		"top" 	manipScaleUpV

		manipLayout;

Maya whines a lot about the UVmanipulation -procedure, saying it has bad nesting and that it has too many parameters of $manipAmt. I'm a MEL noob so I really don't see where the problem is here or why it is happening: and the script editor is bad at explaining

(Some of the annotations are empty but DW about that - i'll fix that later)

Last edited by DeadlyNightshade : 08 August 2012 at 09:32 PM.
 
Old 08 August 2012   #2
try removing all those if...else commands and replace the whole kit and caboodle with switch..case instead:

http://download.autodesk.com/global/docs/maya2012/en_us/files/Controlling_the_flow_of_a_script_switch...case.htm
 
Old 08 August 2012   #3
Thanks. That's a better way of writing it.
Now, the errors.

My global procedure declarations give me the following errors:

"Procedures cannot be nested within each other."
"Procedure has multiple parameters named "$manipAmt"

I don't understand why it's whining. I don't see any nested procedures. All I see is variables inside these procedures.

Last edited by DeadlyNightshade : 08 August 2012 at 10:22 PM.
 
Old 08 August 2012   #4
where exactly are you placing all this code? there doesn't appear to be a problem with what you've posted so I'm guessing you're pasting this inside an existing Maya MEL script, and maybe inside an existing proc definition..?
I'm not sure what else to suggest because as it stands it's fine... (at least it doesn't exhibit the errors you're seeing when I run it)
 
Old 08 August 2012   #5
I see.
Well I'm currently at work so I can't upload/check my script file either. But I'll upload it and post a download link here once I get home.

Thanks for your help.
 
Old 08 August 2012   #6
Well it seems like it's nested after all. My code is located in the global procedure that creates the actual UV toolbar:

global proc textureWindowCreateToolBar(string $toolBar,
	string $editor,
	string $editorCmd)
// Description: Add the texture window toolbar
{

...so things should be cool if I just move these procedures outside so they are not nested correct?

Either way, here is my script:

Download:
http://www.speedyshare.com/sBWzC/scripts.zip
textureWindowCreateToolbar.mel
textureWindowCreateToolbar.res.mel

Files goes to:
c:\Users\ your user \Documents\maya\ maya version \scripts
(warning - these files replace the default Autodesk scripts. Do a backup before you copy)
 
Old 08 August 2012   #7

	/////////////////////
	// UV Manip layout //
	/////////////////////
	setParent ..;

	//
	// Init hidden/shown option var
	//
	if (!`optionVar -exists "showStatusCopyPaste"`) {
		optionVar -intValue "showStatusCopyPaste" 1;
	}

	string $toggleCopyPasteCmd = "\"copyPasteLayout\", " +
								 "\"copyPasteCollapse\", " +
								 "\"\", " + 
								 "\"showStatusCopyPaste\")"; 

	//
	// Set up open/close bar
	//
	setUITemplate -pushTemplate TexWinBarTemplate;

	iconTextButton -vis true
		-parent $gUVTexEditToolBar
		-annotation (uiRes("m_textureWindowCreateToolBar.kShowHideCopyPasteIco  nsAnnot"))
		-i1 textureEditorOpenBar.png  
		-c ("textureWindowCreateToolBar_toggleIcons(-1," + $toggleCopyPasteCmd)
		copyPasteCollapse;

	setUITemplate -popTemplate;
	
	//
	// Set up icons
	//
	// copy/paste controls
	formLayout UVmanipLayout;
	
	setUITemplate -pushTemplate TexWinFloatFieldTemplate;

	global string $uvEntryField;


    int $floatFieldWidth =  $iconSize * 2 + $horizGap;
	floatField 
		-precision 3
		-ed true
        -width $floatFieldWidth
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueTotransfor  mInUAnnot"))
		$uvEntryField;

	setUITemplate -popTemplate;
	
//	
// Note to self: Layout still needs testing
//
	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(6,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipRotCCW;	
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(5,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipRotCW;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(7,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleUp;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(9,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleUpU;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(11,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleUpV;

	setUITemplate -popTemplate;
		
	setUITemplate -pushTemplate TexWinButtonTemplate;		
	
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(2,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveLeft;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(3,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveRight;	
	
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(1,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveUp;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(4,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipMoveDown;	
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(8,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleDown;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(10,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleDownU;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-width $iconSize -height $iconSize		
		-command "UVmanipulation(12,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation (" "))
		manipScaleDownV;		

	setUITemplate -popTemplate;

	
	formLayout -edit
	
		-attachForm     uvEntryField 		"top" 	$edgeMargins
		-attachForm	uvEntryField 		"left" 	0 
		
		-attachControl 	manipRotCCW 		"top" 	$edgeMargins
		-attachControl 	manipRotCCW 		"left" 	$margin uvEntryField
		-attachControl 	manipRotCW 			"top" 	$edgeMargins
		-attachControl 	manipRotCW 			"left" 	$margin manipRotCCW
		
		-attachControl 	manipScaleUp 		"top" 	$edgeMargins
		-attachControl 	manipScaleUp 		"left" 	$margin manipRotCW
		-attachControl 	manipScaleUpU 		"top" 	$edgeMargins
		-attachControl 	manipScaleUpU 		"left" 	$margin manipScaleUp
		-attachControl 	manipScaleUpV 		"top" 	$edgeMargins
		-attachControl 	manipScaleUpV 		"left" 	$margin manipScaleUpU
		
		-attachForm	manipMoveLeft 		"left" 	0
		-attachControl 	manipMoveLeft 		"top" 	$margin uvEntryField
		-attachControl  manipMoveRight 		"left" 	$margin manipMoveLeft
		-attachControl  manipMoveRight 		"top" 	$margin uvEntryField
		-attachControl  manipMoveUp 		"left" 	$margin manipMoveRight
		-attachControl  manipMoveUp 		"top" 	$margin manipRotCCW
		-attachControl  manipMoveBottom		"left" 	$margin manipMoveUp
		-attachControl  manipMoveBottom		"top" 	$margin manipRotCW
		
		-attachControl  manipScaleDown 		"left" 	$margin manipMoveDown
		-attachControl  manipScaleDown 		"top" 	$margin manipScaleUp
		-attachControl  manipScaleDownU		"left" 	$margin manipScaleDown
		-attachControl  manipScaleDownU		"top" 	$margin manipScaleUpU
		-attachControl  manipScaleDownV		"left" 	$margin manipScaleDownU
		-attachControl  manipScaleDownV		"top" 	$margin manipScaleUpV

		UVmanipLayout;		

Error: line 2084: Too many arguments. Expected 1, found 2.
Line 2084 is the last one in the above code: UVmanipLayout

Last edited by DeadlyNightshade : 08 August 2012 at 09:40 PM.
 
Old 08 August 2012   #8
the -attachControl flags should have string string INT string parameters...
 
Old 08 August 2012   #9
Thanks - I've fixed that now. I had forgotten to add the $margin variable on the controllers.
I still get the same kind of error though: Too many arguments.

(the last string of the -attachControl flag isn't necessary btw - it even looks like that in the default code, many controllers end with just $edgeMargins)

EDIT: I don't get it and I'm starting to get angry. I can't see any syntax errors - and I even compared it to the default code (compared in notepad++ side by side - the code is found below) and it has the same structure:

// DEFAULT MOVE and COPY LAYOUT GROUP

	////////////////
	// Copy/Paste //
	////////////////
	setParent ..;

	//
	// Init hidden/shown option var
	//
	if (!`optionVar -exists "showStatusCopyPaste"`) {
		optionVar -intValue "showStatusCopyPaste" 1;
	}

	string $toggleCopyPasteCmd = "\"copyPasteLayout\", " +
								 "\"copyPasteCollapse\", " +
								 "\"\", " + 
								 "\"showStatusCopyPaste\")"; 

	//
	// Set up open/close bar
	//
	setUITemplate -pushTemplate TexWinBarTemplate;

	iconTextButton -vis true
		-parent $gUVTexEditToolBar
		-annotation (uiRes("m_textureWindowCreateToolBar.kShowHideCopyPasteIco  nsAnnot"))
		-i1 textureEditorOpenBar.png  
		-c ("textureWindowCreateToolBar_toggleIcons(-1," + $toggleCopyPasteCmd)
		copyPasteCollapse;

	setUITemplate -popTemplate;

	//
	// Set up icons
	//
	// copy/paste controls
	formLayout copyPasteLayout;

	// UV Entry field. Will allow user to set current uv value
	// of uv in selection list. Will update when selection list
	// changes. 
	//
	// Ideally the fields should update as the selected UV(s)
	// is/are transformed but there is not a good way to do
	// this. Should be an event that exists for scriptJob.

	global string $uvEntryFieldU;
	global string $uvEntryFieldV;

	setUITemplate -pushTemplate TexWinFloatFieldTemplate;

    int $floatFieldWidth =  $iconSize * 2 + $horizGap;
	floatField 
		-precision 3
		-ed true
		-cc "textureWindowUVEntryCommand(1)"
        -width $floatFieldWidth
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueTotransfor  mInUAnnot"))
		$uvEntryFieldU;

	floatField 
		-precision 3
		-ed true
		-cc "textureWindowUVEntryCommand(0)"
        -width $floatFieldWidth
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueTotransfor  mInVAnnot"))
		$uvEntryFieldV;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinButtonTemplate;

	// originally planned to lock current UV values but it's
	// more important to have an update button for the selected
	// UV's coordinates
	iconTextButton 
		-image1 "uvUpdate.png" 
		-annotation (uiRes("m_textureWindowCreateToolBar.kRefreshUVValuesAnnot  "))
		-command "undoInfo -swf false; textureWindowCreateToolBar_isUVTransformed; undoInfo -swf true;"
		-commandRepeatable true -label (uiRes("m_textureWindowCreateToolBar.kRefreshUVValuesLbl"))
		updateValueButton;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinCheckBoxTemplate;

	iconTextCheckBox
		-image1 "uvEntryToggle.png"
		-onCommand "uvEntryTransformModeCommand"
		-offCommand "uvEntryTransformModeCommand"
		-value $gUVEntryTransformMode
		-annotation (uiRes("m_textureWindowCreateToolBar.kUVTransformationEntr  yAnnot"))
		uvEntryTransformModeButton;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-image1 "copyUV.png"
		-command "PolygonCopy"
		-annotation (getRunTimeCommandAnnotation ("PolygonCopy"))
		copyUVButton;

	popupMenu -button 3
		-parent copyUVButton
		-postMenuCommand "PolygonCopyOptions"
		copyUVButtonPopup;

	iconTextButton
		-image1 "pasteUV.png"
		-command "PolygonPaste"
		-annotation (getRunTimeCommandAnnotation ("PolygonPaste"))
		pasteUVButton;

	popupMenu -button 3
		-parent pasteUVButton
		-postMenuCommand "PolygonPasteOptions"
		pasteUVButtonPopup;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinCheckBoxTemplate;

	iconTextCheckBox 
		-image1 "copyUVMode.png" 
		-onCommand		"textureWindowCreateToolBar_copyPasteMode 1"
		-offCommand		"textureWindowCreateToolBar_copyPasteMode 0"
		-annotation (uiRes("m_textureWindowCreateToolBar.kToggleCopyPasteAnnot  "))
		copyModeButton;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-enable false
		-image1 "pasteUDisabled.png"
		-command "textureWindowCreateToolBar_uvPaste 1 0"
		-annotation (uiRes("m_textureWindowCreateToolBar.kPasteUValueAnnot"))
		pasteUButton;

	iconTextButton
		-enable false
		-image1 "pasteVDisabled.png"
		-width $iconSize -height $iconSize
		-command "textureWindowCreateToolBar_uvPaste 0 1"
		-annotation (uiRes("m_textureWindowCreateToolBar.kPasteVValueAnnot"))
		pasteVButton;

	iconTextButton
			-image1 "cycleUVs.png"
			-command "polyRotateUVsByVertex"
			-commandRepeatable true -label (uiRes("m_textureWindowCreateToolBar.kCycleUVsCounterClock  wiseLbl"))
			-annotation (uiRes("m_textureWindowCreateToolBar.kCycleUVsCounterClock  wiseAnnot"))
			cycleUVsButton;

	setUITemplate -popTemplate;

	formLayout -edit
	
		-attachForm     uvEntryFieldU		"top"	$vertGap
		-attachForm		uvEntryFieldU		"left"	0 
		-attachForm     uvEntryFieldV		"top"	$vertGap
		-attachControl  uvEntryFieldV		"left"	$horizGap uvEntryFieldU
		-attachForm     updateValueButton	"top"	0
		-attachControl  updateValueButton	"left"	$horizGap uvEntryFieldV
		-attachForm		uvEntryTransformModeButton	"top"	0
		-attachControl	uvEntryTransformModeButton	"left" $horizGap updateValueButton

		-attachControl	copyUVButton		"top"	$vertGap uvEntryFieldU
		-attachForm		copyUVButton		"left"	0
		-attachControl  pasteUVButton		"top"	$vertGap uvEntryFieldU
		-attachControl  pasteUVButton		"left"	$horizGap copyUVButton
		-attachControl  pasteUButton		"top"	$vertGap uvEntryFieldU
		-attachControl  pasteUButton		"left"	$horizGap pasteUVButton
		-attachControl  pasteVButton		"top"	$vertGap uvEntryFieldU
		-attachControl  pasteVButton		"left"	$horizGap pasteUButton
		-attachControl  copyModeButton		"top"	$vertGap uvEntryFieldU
		-attachControl  copyModeButton		"left"	$horizGap pasteVButton
		-attachControl  cycleUVsButton		"top"   $vertGap uvEntryFieldU
		-attachControl  cycleUVsButton		"left"	$horizGap copyModeButton
		copyPasteLayout;		
*/
// DEFAULT MOVE and COPY LAYOUT GROUP END
//

It's commented out because I'm saving the original code in my script file. Either way, the only differences really are variable names, and that the default code has two fields and some other button types and that's it.

Last edited by DeadlyNightshade : 08 August 2012 at 10:51 PM.
 
Old 08 August 2012   #10
Current code:
	/////////////////////
	// UV Manip layout //
	/////////////////////
	
	setParent ..;

	//
	// Init hidden/shown option var
	//
	if (!`optionVar -exists "showStatusCopyPaste"`) {
		optionVar -intValue "showStatusCopyPaste" 1;
	}

	string $toggleCopyPasteCmd = "\"copyPasteLayout\", " +
								 "\"copyPasteCollapse\", " +
								 "\"\", " + 
								 "\"showStatusCopyPaste\")"; 

	//
	// Set up open/close bar
	//
	
	setUITemplate -pushTemplate TexWinBarTemplate;

	iconTextButton -vis true
		-parent $gUVTexEditToolBar
		-annotation (uiRes("m_textureWindowCreateToolBar.kShowHideCopyPasteIco  nsAnnot"))
		-i1 textureEditorOpenBar.png  
		-c ("textureWindowCreateToolBar_toggleIcons(-1," + $toggleCopyPasteCmd)
		copyPasteCollapse;

	setUITemplate -popTemplate;
		
	//
	// Set up icons
	//

	formLayout uvManipLayout;
	
	global string $uvEntryField;	
	global float $manipAmt;
	$manipAmt=1.0;
	
	setUITemplate -pushTemplate TexWinFloatFieldTemplate;

	floatField 
		-precision 3
		-ed true
        -width 48
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueToManipUVA  nnot"))
		$uvEntryField;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -a $manipAmt"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipRotCCWAnnot"))
		manipRotCCW;	
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -a ($manipAmt * -1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipRotCWAnnot"))
		manipRotCW;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -s ($manipAmt)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleUpAnnot"))
		manipScaleUp;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -su ($manipAmt * 1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleUpUAnnot"))
		manipScaleUpU;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -sv ($manipAmt * 1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleUpVAnnot"))
		manipScaleUpV;

	setUITemplate -popTemplate;
		
	setUITemplate -pushTemplate TexWinButtonTemplate;		
	
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u ($manipAmt * -1) -v 0"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveLeftAnnot"))
		manipMoveLeft;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u $manipAmt -v 0"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveRightAnnot"))
		manipMoveRight;	
	
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u 0 -v $manipAmt"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveUpAnnot"))
		manipMoveUp;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u 0 -v ($manipAmt * -1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveDownAnnot"))
		manipMoveDown;	
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -s ($manipAmt * -1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleDownAnnot"))
		manipScaleDown;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "UVmanipulation(10,$manipAmt)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleDownUAnnot  "))
		manipScaleDownU;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -sv ($manipAmt * -1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleDownVAnnot  "))
		manipScaleDownV;		

	setUITemplate -popTemplate;
	
	formLayout -edit
	
		-attachForm     uvEntryField		"top"	$vertGap
		-attachForm		uvEntryField		"left"	0
		
		-attachControl 	anipRotCCW			"top"	$vertGap
		-attachControl 	anipRotCCW			"left"	$horizGap
		-attachControl 	manipRotCW			"top"	$vertGap					
		-attachControl 	manipRotCW			"left"	$horizGap
		
		-attachControl 	manipScaleUp		"top"	$vertGap
		-attachControl 	manipScaleUp		"left"	$horizGap
		-attachControl 	manipScaleUpU		"top"	$vertGap
		-attachControl 	manipScaleUpU		"left"	$horizGap
		-attachControl 	manipScaleUpV		"top"	$vertGap
		-attachControl 	manipScaleUpV		"left"	$horizGap		
		
		-attachForm		manipMoveLeft		"top"	$vertGap uvEntryField
		-attachControl 	manipMoveLeft		"left"	0
		-attachControl  manipMoveRight		"top"	$vertGap uvEntryField
		-attachControl  manipMoveRight		"left"	$horizGap manipMoveLeft
		-attachControl  manipMoveUp			"top"	$vertGap manipRotCCW		
		-attachControl  manipMoveUp 		"left"	$horizGap manipMoveRight
		-attachControl  manipMoveBottom		"top"	$vertGap manipScaleUp
		-attachControl  manipMoveBottom		"left"	$horizGap manipMoveUp
		
		-attachControl  manipScaleDown		"left"	$horizGap manipMoveBottom
		-attachControl  manipScaleDown		"top"	$vertGap manipScaleUp
		-attachControl  manipScaleDownU		"left"	$horizGap manipScaleDown
		-attachControl  manipScaleDownU		"top"	$vertGap manipScaleUpU
		-attachControl  manipScaleDownV		"left"	$horizGap manipScaleDownU
		-attachControl  manipScaleDownV		"top"	$vertGap manipScaleUpV
		uvManipLayout;

Removed the switch (wasnt needed) and cleaned up the layout. But I STILL get the same error: TOO MANY ARGUMENTS!! :(
 
Old 08 August 2012   #11
check your formLayout flags!!! the -attachForm flag should have THREE params, and -attachControl should have FOUR. you have at least one -attachForm with 4 params...

If you can't debug where the error lies, simply REMOVE ALL the offending code and put it back line by line... you don't need any of those formLayout edits to actually run the code successfully, only to make it look right. Take them all out and add then back one by one.
 
Old 08 August 2012   #12
Great! Thanks.
The editor now starts up and I have the buttons. Some of the commands will have to be tweaked but that's another issue.
The high priority issue now is fixing the floatField. As of now, entering a new value into it does not update the variable $manipAmt; - why?

	//
	// Set up icons
	//

	formLayout uvManipLayout;
	
	global string $uvEntryField;
	global float $manipAmt;
	$manipAmt=1.0;
	
	setUITemplate -pushTemplate TexWinFloatFieldTemplate;

	floatField 
		-precision 3
		-ed true
        -width 48
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueToManipUVA  nnot"))
		-value $manipAmt;
		$uvEntryField;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinButtonTemplate;


I guess I need a -cc flag and a command that takes the value of the floatField (uvEntryField) and updates $manipAmt with it. But how do I get the value from a floatField?

EDIT: What would be the correct syntax on the changeCommand flag?
	floatField 
		-precision 3
		-ed true
        -width 48
		-changeCommand ('$manipAmt = "floatField -query -value $uvEntryField"')
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueToManipUVA  nnot"))
		$uvEntryField;

Last edited by DeadlyNightshade : 08 August 2012 at 10:54 PM.
 
Old 08 August 2012   #13
MEL doesn't support ' quotes, only " (doubles) so:
-changeCommand "$manipAmt = `floatField -query -value $uvEntryField`"
however, all code callbacks are executed in the global scope, so unless $uvEntryField is a global variable, this won't work. Doing any of this with global variables is not the best approach to be honest anyway. Fortunately, MEL UI controls have a trick whereby you can reference the control value directly by refering to it as #1:
-changeCommand "$manipAmt = #1"
should work. if your control has more than one value, you can use #2, #3 and #4 to refer to it's other values.
 
Old 08 August 2012   #14
Thanks a lot Nathan, you've been very helpful. That #1 -thing really did the trick.

Now I just need to fix my commands. Code is below (I stripped away the -ac button stuff coz it's already working):
formLayout uvManipLayout;
	
	global string $uvEntryField;
	global float $manipAmt;
	$manipAmt=1.0;
		
	
	setUITemplate -pushTemplate TexWinFloatFieldTemplate;

	floatField 
		-precision 3
		-ed true
        -width 48
		-changeCommand "$manipAmt = #1" // reads new floatField input
		-annotation (uiRes("m_textureWindowCreateToolBar.kEnterValueToManipUVA  nnot"))
		$uvEntryField;

	setUITemplate -popTemplate;

	setUITemplate -pushTemplate TexWinButtonTemplate;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -a $manipAmt"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipRotCCWAnnot"))
		manipRotCCW;	
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -a ($manipAmt * -1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipRotCWAnnot"))
		manipRotCW;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -su ($manipAmt)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleUAnnot"))
		manipScaleU;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -su ($manipAmt) -sv ($manipAmt)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleUVAnnot"))
		manipScaleUV;
		
	setUITemplate -popTemplate;
		
	setUITemplate -pushTemplate TexWinButtonTemplate;		
	
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u ($manipAmt * -1) -v 0"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveLeftAnnot"))
		manipMoveLeft;
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u $manipAmt -v 0"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveRightAnnot"))
		manipMoveRight;	
	
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u 0 -v $manipAmt"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveUpAnnot"))
		manipMoveUp;

	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -u 0 -v ($manipAmt * -1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipMoveDownAnnot"))
		manipMoveDown;	
		
	iconTextButton
		-image1 "updatePsdTextureEditor.png"
		-command "polyEditUV -sv ($manipAmt * 1)"
		-annotation (getRunTimeCommandAnnotation ("m_textureWindowCreateToolBar.kmanipScaleVAnnot"))
		manipScaleV;
		
	setUITemplate -popTemplate;
	
	formLayout -edit
	
// lots of -attachControls and -attachForms

		uvManipLayout;			

I've also rearranged the buttons somewhat, and removed 3 scale buttons (because you really don't need negative ones).

Now, the last(?) problem is the following:

The scale (manipScaleUV, manipScaleU, manipScaleV) and the rotate buttons (manipRotCW, manipRotCCW) work, but acts very weird. When the commands are run, Maya considers the pivot of my selected shell to be slightly outside the BOTTOM LEFT corner of my selection - so everything scales from/to or rotates around that area. It's like it doesn't "remember" that the pivot is actually in the center of the selection. This is a very annoying issue as it causes all my scale and rotate operations to skew/offset the shells.

I'm also going to add buttons to the left of the input field for quickly manipulating the value of the floatField. For example:
+/- 10.0, 1.0, 0.1, and 0.01. The idea here is to have positive increments on left click (normal command) and then use the popupMenu for negative increments (using the -postMenuCommand), and parent it to the positive button. This should - in theory at least - give me the ability to have two commands on one button, correct?
 
Old 08 August 2012   #15
A quick look at polyEditUV in the manual will show you the pivotU and pivotV keywords. This could be a solution to your last(?) problem.

Rather than using the popup menu for your negative increments, I think I would have used ctrl-left click. Just a bit more user-friendly imo.

David
__________________
http://www.djx.com.au
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:10 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.