Anonymous Script ?

188 views
Skip to first unread message

Christopher.

unread,
Oct 17, 2015, 11:08:58 PM10/17/15
to Python Programming for Autodesk Maya
From what I know, if a MEL script doesn't have a command to which one should use, you can look for the global function, and run the function name; what if that is giving, no procedure found and you know it's not a paths problem ?

Justin Israel

unread,
Oct 17, 2015, 11:21:06 PM10/17/15
to Python Programming for Autodesk Maya

Is the script in a proper Maya scripts location?
Have you checked the file and confirmed that it has a global proc that can be called?


On Sun, 18 Oct 2015 4:09 PM Christopher. <crestchr...@gmail.com> wrote:
From what I know, if a MEL script doesn't have a command to which one should use, you can look for the global function, and run the function name; what if that is giving, no procedure found and you know it's not a paths problem ?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c189227e-cfc6-42ce-862b-6f3a5784c148%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher.

unread,
Oct 18, 2015, 2:20:26 PM10/18/15
to Python Programming for Autodesk Maya
The script is located in the proper MEL path, that I can testify; although, there is no global function.


On Saturday, October 17, 2015 at 11:21:06 PM UTC-4, Justin Israel wrote:

Is the script in a proper Maya scripts location?
Have you checked the file and confirmed that it has a global proc that can be called?


On Sun, 18 Oct 2015 4:09 PM Christopher. <crestchr...@gmail.com> wrote:
From what I know, if a MEL script doesn't have a command to which one should use, you can look for the global function, and run the function name; what if that is giving, no procedure found and you know it's not a paths problem ?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Oct 18, 2015, 2:35:23 PM10/18/15
to Python Programming for Autodesk Maya

On Mon, 19 Oct 2015 7:20 AM Christopher. <crestchr...@gmail.com> wrote:

The script is located in the proper MEL path, that I can testify; although, there is no global function.

There you go. If it has no global proc, then I don't think you are going to be able to call anything in it. Nor will it automatically run anything when Maya sources it.



On Saturday, October 17, 2015 at 11:21:06 PM UTC-4, Justin Israel wrote:

Is the script in a proper Maya scripts location?
Have you checked the file and confirmed that it has a global proc that can be called?


On Sun, 18 Oct 2015 4:09 PM Christopher. <crestchr...@gmail.com> wrote:

From what I know, if a MEL script doesn't have a command to which one should use, you can look for the global function, and run the function name; what if that is giving, no procedure found and you know it's not a paths problem ?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cde01e8d-8cbf-45a4-b689-61641ec58eb8%40googlegroups.com.

Carlos Rico

unread,
Oct 18, 2015, 2:43:38 PM10/18/15
to python_in...@googlegroups.com
source it?

Carlos Rico Adega
-------------------------------------
LinkedIn
carlos....@gmail.com

2015-10-18 20:20 GMT+02:00 Christopher. <crestchr...@gmail.com>:
The script is located in the proper MEL path, that I can testify; although, there is no global function.

On Saturday, October 17, 2015 at 11:21:06 PM UTC-4, Justin Israel wrote:

Is the script in a proper Maya scripts location?
Have you checked the file and confirmed that it has a global proc that can be called?


On Sun, 18 Oct 2015 4:09 PM Christopher. <crestchr...@gmail.com> wrote:
From what I know, if a MEL script doesn't have a command to which one should use, you can look for the global function, and run the function name; what if that is giving, no procedure found and you know it's not a paths problem ?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cde01e8d-8cbf-45a4-b689-61641ec58eb8%40googlegroups.com.

Christopher.

unread,
Oct 18, 2015, 6:47:29 PM10/18/15
to Python Programming for Autodesk Maya
Source. I originally though the global function was rotateProjection, until I realized it didn't encapsulate the entire script; unless it doesn't have to ? I suppose if not, someone on this list will inform me, or I hope someone will.

//Additional Variables

string $dir2d = "";
string $projName = "";
string $fileName = "";
string $placeName = "";
string $productName = "";
string $camProductName = "";
string $remapName = "";
string $multDivName = "";
string $Dir = "";
int $camSetExists = 0;


global proc rotateProjection( string $placementNode, string $direction )
{
 
if($direction == "PosX")  //Left
 
{
 xform
-ro 0 -90 0 $placementNode;
 
}
 
if($direction == "NegX")  //Right
 
{
 xform
-ro 0 90 0 $placementNode;
 
}
 
if($direction == "PosY")  //Bottom
 
{
 xform
-ro 90 0 0 $placementNode;
 
}
 
if($direction == "NegY")  //Top
 
{
 xform
-ro -90 0 0 $placementNode;
 
}
 
//if($direction == "PosZ")  No Case: Default Position  //Front
 
if($direction == "NegZ")  //Back
 
{
 xform
-ro 0 180 0 $placementNode;
 
}
}


//Makes and Sets up Camera Node Network
global proc setupCameraNodes()
{
if(`objExists "RenBakeCam1"`)
{
//Makes sure only 1 camera bake network exists to keep everything as clean as it can be.
$camSetExists
=1;
print "Camera Nodes Already Exist \n";
}
else{
camera
-name "RenBakeCam1" -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30; objectMoveCommand; cameraMakeNode 1 "";
shadingNode
-asUtility "samplerInfo" -name "sampInfo1";
shadingNode
-asUtility "vectorProduct" -name "CamVec1";
setAttr
CamVec1.operation 3; //sets op type to Vector Matrix Product
setAttr
CamVec1.normalizeOutput true; //sets normalizeOutput to ON
//Connects to Vector Product for Object Normal in World Space
connectAttr
-f sampInfo1.normalCamera CamVec1.input1;
connectAttr
-f RenBakeCam1.matrix CamVec1.matrix;
print "Camera Node Setup Complete \n";
}
}




//Generates all nodes needed for the selected number of textures, then links them to the camera and output chains
global proc setupTextureNodes(int $numProjections)
{
//Sets name and number of directions
string $DirList[];
global string $PosZ_ProductNode;
global string $PosZ_RemapNode;
//variables for file attachment
global string $TopNode;
global string $BottomNode;
global string $LeftNode;
global string $RightNode;
global string $FrontNode;
global string $BackNode;
//variables for shader output network
string $colorSum = `shadingNode -asUtility "plusMinusAverage" -name "ColorSum1"`;
string $valueSum = `shadingNode -asUtility "plusMinusAverage" -name "ValueSum1"`;
string $remapSum = `shadingNode -asUtility "remapValue" -name "RemapSum1"`;
string $finalColor = `shadingNode -asUtility "multiplyDivide" -name "FinalColor1"`;
string $shaderName = `shadingNode -asShader "blinn" -name "BlinnName"`;
sets
-renderable true -noSurfaceShader true -empty -name ($shaderName + "SG");


print $numProjections;
if($numProjections == 3)
{
 
//$DirList[] = {"PosZ","PosY","PosX"};
 $DirList
[0] = "PosZ";
 $DirList
[1] = "PosY";
 $DirList
[2] = "PosX";
 
print "Making 3 projections... \n";
}
if($numProjections == 6)
{
 
//$DirList[] = {"PosZ","NegY","NegZ","PosY","PosX","NegX"};
 $DirList
[0] = "PosZ";
 $DirList
[1] = "NegY";
 $DirList
[2] = "NegZ";
 $DirList
[3] = "PosY";
 $DirList
[4] = "PosX";
 $DirList
[5] = "NegX";
 
print "Making 6 projections.... \n";
}
print $DirList;
int $plusMinusInputCounter = 1;


//Generates Shader Output chain, and calls Camera creation chain, which may not output if a camera chain already exists.
setupCameraNodes
();


//Generates nodes for Output Chain
//variables named as a result of the operation as more than one output network/shader can exist in a given scene


setAttr
($finalColor + ".operation") 2; //sets node to divide
connectAttr
-f ($colorSum + ".output3D") ($finalColor + ".input1");
connectAttr
-f ($valueSum + ".output1D") ($remapSum + ".inputValue");
connectAttr
-f ($remapSum + ".outValue") ($finalColor + ".input2X");
connectAttr
-f ($remapSum + ".outValue") ($finalColor + ".input2Y");
connectAttr
-f ($remapSum + ".outValue") ($finalColor + ".input2Z");
//final color to shader node occurs at end of script
print "Output Node Setup Complete \n";


for($Dir in $DirList){


//Sets up name variables for each direction, $Dir taken from For Loop
$dir2d
= $Dir + "_2d1";
$projName
= $Dir + "_Projection1";
$fileName
= $Dir + "_File1";
$placeName
= $Dir + "_Placement1";
$productName
= $Dir + "_Product1";
$camProductName
= $Dir + "_CamProduct1";
$remapName
= $Dir + "_Remap1";
$multDivName
= $Dir + "_colorXRemap1";


//Creates File Projection Network
$projName
= `shadingNode -asUtility "projection" -name $projName`;
$fileName
= `shadingNode -asTexture "file" -name $fileName`;






//Notes name of file nodes for file assignment
switch($Dir)
{
case "PosZ":
 
//front
 $FrontNode
= $fileName;
 
break;
case "PosY":
 
//bottom
 $BottomNode
= $fileName;
 
break;
case "PosX":
 
//left
 $LeftNode
= $fileName;
 
break;
case "NegZ":
 
//back
 $BackNode
= $fileName;
 
break;
case "NegY":
 
//top
 $TopNode
= $fileName;
 
break;
case "NegX":
 
//right
 $RightNode
= $fileName;
 
break;
default:
 
print ("UNKNOWN DIRECTION, VALUE FOR CAMERA NOT SET, FILE ASSIGNMENT WILL FAIL \n");
 
break;
}


$placeName
= `shadingNode -asUtility "place3dTexture" -name $placeName`;
$dir2d
= `shadingNode -asUtility "place2dTexture" -name $dir2d`;
//Links nodes together as default projection normally does
connectAttr
-f ($placeName + ".worldInverseMatrix[0]") ($projName + ".placementMatrix");
connectAttr
-f ($fileName + ".outColor") ($projName + ".image");
connectAttr
-f ($dir2d + ".coverage") ($fileName + ".coverage");
connectAttr
-f ($dir2d + ".translateFrame") ($fileName + ".translateFrame");
connectAttr
-f ($dir2d + ".rotateFrame") ($fileName + ".rotateFrame");
connectAttr
-f ($dir2d + ".mirrorU") ($fileName + ".mirrorU");
connectAttr
-f ($dir2d + ".mirrorV") ($fileName + ".mirrorV");
connectAttr
-f ($dir2d + ".stagger") ($fileName + ".stagger");
connectAttr
-f ($dir2d + ".wrapU") ($fileName + ".wrapU");
connectAttr
-f ($dir2d + ".wrapV") ($fileName + ".wrapV");
connectAttr
-f ($dir2d + ".repeatUV") ($fileName + ".repeatUV");
connectAttr
-f ($dir2d + ".offset") ($fileName + ".offset");
connectAttr
-f ($dir2d + ".rotateUV") ($fileName + ".rotateUV");
connectAttr
-f ($dir2d + ".noiseUV") ($fileName + ".noiseUV");
connectAttr
-f ($dir2d + ".vertexUvOne") ($fileName + ".vertexUvOne");
connectAttr
-f ($dir2d + ".vertexUvTwo") ($fileName + ".vertexUvTwo");
connectAttr
-f ($dir2d + ".vertexUvThree") ($fileName + ".vertexUvThree");
connectAttr
-f ($dir2d + ".vertexCameraOne") ($fileName + ".vertexCameraOne");
connectAttr
-f ($dir2d + ".outUV") ($fileName + ".uv");
connectAttr
-f ($dir2d + ".outUvFilterSize") ($fileName + ".uvFilterSize");
///////////////
print ("Projection Node Output Complete for " + $Dir + " \n");


//Function Call to rotate Place3d Node to correct location
rotateProjection
($placeName , $Dir);




//creates and sets nodes for vector functions
$productName
= `shadingNode -asUtility "vectorProduct" -name $productName`;
$camProductName
= `shadingNode -asUtility "vectorProduct" -name $camProductName`;
$remapName
= `shadingNode -asUtility "remapValue" -name $remapName`;
$multDivName
= `shadingNode -asUtility "multiplyDivide" -name $multDivName`;
setAttr
($productName + ".operation") 3; //sets to Vector Matrix Product
setAttr
($productName + ".input2Z") -1;
setAttr
($camProductName + ".operation") 1; //sets to Dot Product
setAttr
($camProductName + ".normalizeOutput") true; //normalizes output
setAttr
($remapName + ".value[0].value_Position") 0.244;
setAttr
($remapName + ".value[0].value_FloatValue") 0;
setAttr
($remapName + ".value[0].value_Interp") 2; //sets to smooth interpolation




//connects camera, output, projection and vector chains
if( $Dir == "PosZ" )
{
//Sets up primary node chain, all other chains have a dependency on the Dir_Product vectorProduct node of this chain
connectAttr
-f ($projName + ".outColor") ($multDivName + ".input1");
connectAttr
-f ($placeName + ".worldMatrix") ($productName + ".matrix");
connectAttr
-f ($productName + ".output") ($camProductName + ".input1");
connectAttr
-f CamVec1.output ($camProductName + ".input2");
connectAttr
-f ($camProductName + ".outputX") ($remapName + ".inputValue");
connectAttr
-f ($remapName + ".outValue") ($multDivName + ".input2X");
connectAttr
-f ($remapName + ".outValue") ($multDivName + ".input2Y");
connectAttr
-f ($remapName + ".outValue") ($multDivName + ".input2Z");
connectAttr
-f ($multDivName + ".output") ($colorSum + ".input3D[0]");
connectAttr
-f ($remapName + ".outValue") ($valueSum + ".input1D[0]");
$PosZ_ProductNode
= $productName;
$PosZ_RemapNode
= $remapName;
setAttr
($productName + ".input1Z") 1;
////////
print "Node Chain Complete \n";
}
else
{
//Sets up node chain for all but the first
connectAttr
-f ($projName + ".outColor") ($multDivName + ".input1");
connectAttr
-f ($placeName + ".worldMatrix") ($productName + ".matrix");
//ONLY TRIGGERS ON NON-FIRST RUN
connectAttr
-f ($PosZ_ProductNode + ".input1") ($productName + ".input1");
connectAttr
-f ($PosZ_RemapNode + ".value[0]") ($remapName + ".value[0]");
//
connectAttr
-f ($productName + ".output") ($camProductName + ".input1");
connectAttr
-f CamVec1.output ($camProductName + ".input2");
connectAttr
-f ($camProductName + ".outputX") ($remapName + ".inputValue");
connectAttr
-f ($remapName + ".outValue") ($multDivName + ".input2X");
connectAttr
-f ($remapName + ".outValue") ($multDivName + ".input2Y");
connectAttr
-f ($remapName + ".outValue") ($multDivName + ".input2Z");
connectAttr
-f ($multDivName + ".output") ($colorSum + ".input3D[" + $plusMinusInputCounter + "]");
connectAttr
-f ($remapName + ".outValue") ($valueSum + ".input1D[" + $plusMinusInputCounter + "]");
$plusMinusInputCounter
= $plusMinusInputCounter + 1;
////////
print "Node Chain Complete \n";
} //end else


} //end for


//connects into shader node
connectAttr
-f ($finalColor + ".output") ($shaderName + ".color");
$file1
= `textField -query -text file1Text`; //front
$file2
= `textField -query -text file2Text`; //bottom
$file3
= `textField -query -text file3Text`; //left
$file4
= `textField -query -text file4Text`; //back
$file5
= `textField -query -text file5Text`; //top
$file6
= `textField -query -text file6Text`; //right




//HardLink the texture links from the GUI into the File nodes
if($numProjections == 3)
{
 
//$DirList[] = {"PosZ","PosY","PosX"}; Front Bottom Left
 setAttr
($FrontNode + ".fileTextureName") -type "string" $file1;
 setAttr
($BottomNode + ".fileTextureName") -type "string" $file2;
 setAttr
($LeftNode + ".fileTextureName") -type "string" $file3;
 
/////////
 
print "file nodes set \n";
}


if($numProjections == 6)
{
 
//$DirList[] = {"PosZ","NegY","NegZ","PosY","PosX","NegX"}; Front Top Back Bottom Left Right
 setAttr
($FrontNode + ".fileTextureName") -type "string" $file1;
 setAttr
($BottomNode + ".fileTextureName") -type "string" $file2;
 setAttr
($LeftNode + ".fileTextureName") -type "string" $file3;
 setAttr
($BackNode + ".fileTextureName") -type "string" $file4;
 setAttr
($RightNode + ".fileTextureName") -type "string" $file6;
 setAttr
($TopNode + ".fileTextureName") -type "string" $file5;
 
print "file nodes set \n";
}


} //end proc


//GUI
int $numProjections; //initializes $numProjections


if (`window -exists BlendedBoxMapGui`)
  deleteUI
BlendedBoxMapGui;
 
 window
-widthHeight 370 450 -title "Maya Blended Box Map Maker" BlendedBoxMapGui;
 
 frameLayout
-width 100 -height 100 -label "Num Projections" RadioFrame;
 setParent
RadioFrame;
 columnLayout
RadioColumn;
 setParent
RadioColumn;
 radioCollection
AllRadioButtons;
// radioButton -label "3" -changeCommand "$numProjections = 3" -select RadioButton1;
 radioButton
-label "6" -changeCommand "$numProjections = 6" -select RadioButton2;
 
 text
-label "Texture Links:";
 rowColumnLayout
-numberOfColumns 3 -columnAttach 1 "right" 0
   
-columnWidth 1 150 -columnWidth 2 250 -columnWidth 3 100;
 text
-label "Front";
 
string $file1 = `textField file1Text`;
 button
-label "Browse" -command "$file1 = `fileDialog`; textField -edit -text $file1 file1Text" BrowseFile1;
 text
-label "Bottom";
 
string $file2 = `textField file2Text`;
 button
-label "Browse" -command "$file2 = `fileDialog`; textField -edit -text $file2 file2Text" BrowseFile2;
 text
-label "Left";
 
string $file3 = `textField file3Text`;
 button
-label "Browse" -command "$file3 = `fileDialog`; textField -edit -text $file3 file3Text" BrowseFile3;
 text
-label "Back";
 
string $file4 = `textField file4Text`;
 button
-label "Browse" -command "$file4 = `fileDialog`; textField -edit -text $file4 file4Text" BrowseFile4;
 text
-label "Top";
 
string $file5 = `textField file5Text`;
 button
-label "Browse" -command "$file5 = `fileDialog`; textField -edit -text $file5 file5Text" BrowseFile5;
 text
-label "Right";
 
string $file6 = `textField file6Text`;
 button
-label "Browse" -command "$file6 = `fileDialog`; textField -edit -text $file6 file6Text" BrowseFile6;
 button
-label "Generate Shader Network" -command "setupTextureNodes($numProjections)" goButton;
 
$numProjections
= 6;
showWindow
BlendedBoxMapGui;


On Sunday, October 18, 2015 at 2:43:38 PM UTC-4, Carlos Rico wrote:
source it?

Carlos Rico Adega
-------------------------------------
LinkedIn
carlos....@gmail.com

2015-10-18 20:20 GMT+02:00 Christopher. <crestchr...@gmail.com>:
The script is located in the proper MEL path, that I can testify; although, there is no global function.

On Saturday, October 17, 2015 at 11:21:06 PM UTC-4, Justin Israel wrote:

Is the script in a proper Maya scripts location?
Have you checked the file and confirmed that it has a global proc that can be called?


On Sun, 18 Oct 2015 4:09 PM Christopher. <crestchr...@gmail.com> wrote:
From what I know, if a MEL script doesn't have a command to which one should use, you can look for the global function, and run the function name; what if that is giving, no procedure found and you know it's not a paths problem ?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Christopher.

unread,
Oct 23, 2015, 8:51:02 PM10/23/15
to Python Programming for Autodesk Maya
Safe to assume no one has the answer and I need to put it in the trash bin ?

Justin Israel

unread,
Oct 24, 2015, 1:16:01 AM10/24/15
to Python Programming for Autodesk Maya


On Sat, 24 Oct 2015 1:51 PM Christopher. <crestchr...@gmail.com> wrote:

Safe to assume no one has the answer and I need to put it in the trash bin ?

It's safe to assume that people have tried to help answer your questions, and have since probably give  up on this particular thread.

Your script has code located in the global scope that is going to run every time it is sourced. that means if you source this script manually, it would launch a gui. I never wrote much MEL from scratch, but I believe this is bad practice. If I remember correctly, if you name a global proc the same as the file name, Maya will call it when it sources the script at startup. Otherwise you can/should just have one or more global procs that you want someone to call from MEL, to launch your tool or command.

What goal do you want to achieve here? I don't know what this file is called but it probably doesn't matter because it assumes  you will source it to get it to launch the GUI. Look up the "source" Mel command.
Or... place this thread in the trash as you suggested, if this still doesn't solve your issue.

Justin

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8796292d-a071-449b-829b-696f4ddcf241%40googlegroups.com.

Crest Christopher

unread,
Oct 24, 2015, 1:35:42 AM10/24/15
to python_in...@googlegroups.com
I hoped to get it to work. 

Justin Israel wrote:
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0%2B_E-bKvN%2BBZdcDJPJMGVbvB3fC%3DfW98vqXy-KBxeKEQ%40mail.gmail.com.

Justin Israel

unread,
Oct 24, 2015, 2:07:11 AM10/24/15
to python_in...@googlegroups.com
On Sat, Oct 24, 2015 at 6:35 PM Crest Christopher <crestchr...@gmail.com> wrote:
I hoped to get it to work. 

And did my last reply help at all?
 

Carlos Rico

unread,
Oct 24, 2015, 5:21:58 AM10/24/15
to python_in...@googlegroups.com
Paste in Script Editor and execute. I think it is the only why taking into account how the script is written. If you want to run it with a function name I guess it has to be rewritten to support that.

Carlos Rico Adega
-------------------------------------
LinkedIn
carlos....@gmail.com

Christopher.

unread,
Oct 24, 2015, 10:35:09 AM10/24/15
to Python Programming for Autodesk Maya
I added the source command, and I used the globalProc within the script to execute the script but my question is; shouldn't the globalproc encapsulate the entire script ? The first globalProc in the script is called rotateProjection, if I execute rotateProjection, I get the typical Cannot find Procedure error ?

Justin Israel wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Oct 24, 2015, 3:03:55 PM10/24/15
to Python Programming for Autodesk Maya


On Sun, 25 Oct 2015 3:35 AM Christopher. <crestchr...@gmail.com> wrote:

I added the source command, and I used the globalProc within the script to execute the script but my question is; shouldn't the globalproc encapsulate the entire script ?

No

The first globalProc in the script is called rotateProjection, if I execute rotateProjection, I get the typical Cannot find Procedure error ?

Strange. Seems like the script wasn't successfully sourced.

The script is written badly. It has loose code in the global scope of the file, at the bottom. Just that loose code should be encapsulated in a global proc. If it is named the same as the file, Maya will execute it automatically if you put it in the scripts location. This would probably be bad since it launches a gui. So it needs a global proc name that doesn't match the file name.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--


You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.

To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.



For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/09827b7c-2f03-4796-becb-705fba25c26a%40googlegroups.com.

Crest Christopher

unread,
Oct 24, 2015, 6:37:49 PM10/24/15
to python_in...@googlegroups.com
The script can't be renamed anything but rotateProjection or it doesn't matter ?

Justin Israel wrote:

Christopher.

unread,
Oct 24, 2015, 6:57:41 PM10/24/15
to Python Programming for Autodesk Maya
From what I know, one should typically encapsulate MEL script in a GlobalProc, then that name of the GlobalProc is run.  In this case with this script I don't know what it is needed to run, for this badly written script. I do believe if you want, you can learn how to script fast, if you want to do it correctly with an understanding, that takes time, for some more time then others.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--


You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.

To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.



For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Oct 25, 2015, 3:47:19 AM10/25/15
to python_in...@googlegroups.com
On Sun, Oct 25, 2015 at 11:57 AM Christopher. <crestchr...@gmail.com> wrote:
From what I know, one should typically encapsulate MEL script in a GlobalProc, then that name of the GlobalProc is run.  In this case with this script I don't know what it is needed to run, for this badly written script. I do believe if you want, you can learn how to script fast, if you want to do it correctly with an understanding, that takes time, for some more time then others.


You do not need to encapsulate the entire contents of the script inside a global proc. Global procs are those that will be exported into the main Maya namespace, when you source the script. A special case is if a global proc has the same name as the file (ie  myScript.mel & global proc myScript ). In this case, Maya will automatically execute that global proc as an entry point to your script. 
 

On Saturday, October 24, 2015 at 6:37:49 PM UTC-4, Christopher. wrote:
The script can't be renamed anything but rotateProjection or it doesn't matter ?

In your particular script, you would not want that code to run automatically, because it wants to create a UI tool. You would want to wrap just the loose amount of code in a global proc that isn't the same name as the file. This will give you an exported proc that can be called from Maya after you source the file.
 

Justin Israel wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--


You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.

To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.



For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8815719c-2e87-4f55-9762-cb42a2dabf2f%40googlegroups.com.

Nicolas Combecave

unread,
Oct 25, 2015, 5:09:00 AM10/25/15
to python_in...@googlegroups.com

We have two kind of scripts:
-Scripts that define procedures, and only contain procedures. They are safe to be sourced any time and never modify your scene or maya-ui in any way.
-Scripts that call those procedures, and those scripts are used for various things like rigging a character, exporting data, creating a tool ui, etc... Those ones need to have code outside otherwise, nothing happens. Those scritps are only sourced when used in tools, or inside characters creation pipeline.

So maybe a good idea would be you treat this script the same:

Make it with so it has only procedures. If you want to call one of those procedures, from a shelf button or the script editor, you source it, then call the procedure you want.

Note that procedures you want to call from outside the script need to be global. Procedures that are only relevant to the tool, usually are in the same .mel file, and can be local (without the "global" statement in their declaration).



Christopher.

unread,
Oct 25, 2015, 11:37:46 AM10/25/15
to Python Programming for Autodesk Maya
combi reply was informative and so what yours, Justin.  From your reply Justin I don't understand the following, particularly the segments of your reply in italics ?

You do not need to encapsulate the entire contents of the script inside a global proc. Global procs are those that will be exported into the main Maya namespace, when you source the script. A special case is if a global proc has the same name as the file (ie  myScript.mel & global proc myScript ). In this case, Maya will automatically execute that global proc as an entry point to your script. 

combi from your reply I didn't understand segments of your reply in italics ? :-)

We have two kind of scripts:
-Scripts that define procedures, and only contain procedures. They are safe to be sourced any time and never modify your scene or maya-ui in any way.
-Scripts that call those procedures, and those scripts are used for various things like rigging a character, exporting data, creating a tool ui, etc... Those ones need to have code outside otherwise, nothing happens. Those scritps are only sourced when used in tools, or inside characters creation pipeline.

So maybe a good idea would be you treat this script the same:

Make it with so it has only procedures. If you want to call one of those procedures, from a shelf button or the script editor, you source it, then call the procedure you want.

Note that procedures you want to call from outside the script need to be global. Procedures that are only relevant to the tool, usually are in the same .mel file, and can be local (without the "global" statement in their declaration).


I'm still at a loss, on how to fix this script so it will work ?


 I want to understand how to in five seconds, but it's not happening ;-(


Justin Israel wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--


You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.

To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.



For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Nicolas Combecave

unread,
Oct 25, 2015, 1:26:07 PM10/25/15
to python_in...@googlegroups.com
Mmm I think nobody here understood mel scripting in 5 seconds...


Justin Israel wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--


You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.

To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.



For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/Zi9tMVXanqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7970053b-6b91-440f-97bc-42a05e0ef75d%40googlegroups.com.

Crest Christopher

unread,
Oct 25, 2015, 1:27:02 PM10/25/15
to python_in...@googlegroups.com
Figure of speech ;-)

Nicolas Combecave wrote:

Justin Israel

unread,
Oct 25, 2015, 2:43:32 PM10/25/15
to python_in...@googlegroups.com

At this point, I think we are spending too long teaching Mel basics, when you could probably give the Maya scripting docs a read. You should read about how to write Mel, and what a global proc is, and how to execute Mel.

I'm not sure how to rephrase my last reply differently, but I will try. When you open the script editor and typey-typey, you are running code in a global namespace. This means it is a shared scope across the Maya application. Procedures defined in a Mel script that have the global keyword will be "exported" from the script, into that shared namespace, so that you can run the procs from the script editor. The reason to use global procs are so that they can be the main important procedures to make your script do things from the outside world. Non global procs are not visible from the script editor. They are only internal to the script, to do various private functionality.

A special feature of Maya and Mel is that Maya can run your script for you, if the script makes sense to be run automatically, in order to set stuff up in Maya at startup. An example would be a custom menu script, where you always want your menus installed every time Maya starts. To accomplish this, you name a global proc the same as the file. When Maya sources it on startup, it will call the global proc with the same name, and poof... you have menus (of that is what your script did)

Can't think of how much more to say on this topic.


Crest Christopher

unread,
Oct 25, 2015, 3:15:50 PM10/25/15
to python_in...@googlegroups.com
I understand local and global procedures, problems putting a script together may be my only setback.

How can the script be fixed, if it can be fixed, it sounds as though a band-aid solution, here or there to the script won't fix it, it needs to be re-written ?

Justin Israel wrote:

Justin Israel

unread,
Oct 25, 2015, 3:27:04 PM10/25/15
to python_in...@googlegroups.com

On Mon, 26 Oct 2015 8:15 AM Crest Christopher <crestchr...@gmail.com> wrote:

I understand local and global procedures, problems putting a script together may be my only setback.

How can the script be fixed, if it can be fixed, it sounds as though a band-aid solution, here or there to the script won't fix it, it needs to be re-written ?

I'm just going to repeat the same answers that were already given to you

1) wraps that loose bit of code at the bottom inside a global proc, and then call that global proc when you want to launch the GUI

2) or just always use the "source" Mel command to run the script

To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/562D2A6D.6050004%40gmail.com.

Nicolas Combecave

unread,
Oct 25, 2015, 3:45:45 PM10/25/15
to python_in...@googlegroups.com
I don't want to sound harsh on you Christopher, but how about you try yourself assembling a very simple mel script, let's say that would only print things...
It would let you explore differences about private/global procedures, or code outside any procedure, and the meaning of those concepts when sourcing happens, and also the importance of naming the script and the procedures inside, its location on the path defined by MAYA_SCRIPT_PATH environment variable, etc...

I think anyone around here has gone a somehow similar path, and you'll gain knowledge about the very basics of how maya  deals with mel scripts.

We could spend time to refactor the code of your script, but it probably opens the door to so many requests from you for changing a few things here and there, that , at least for me, keeps me away from doing that.

Again I don't want to be rude on you, but I think it is the proper way to behave to keep this list as healthy as it has been for so many years now.


Reply all
Reply to author
Forward
0 new messages