On Sat, 24 Oct 2015 1:51 PM Christopher. <[email protected]> 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
On Sunday, October 18, 2015 at 6:47:29 PM UTC-4, Christopher. wrote:
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 <http://www.linkedin.com/pub/carlos-rico/6/58/325>
[email protected]
2015-10-18 20:20 GMT+02:00 Christopher. <[email protected]>:
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. <[email protected]> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/c189227e-cfc6-42ce-862b-6f3a5784c148%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/c189227e-cfc6-42ce-862b-6f3a5784c148%40googlegroups.com?utm_medium=email&utm_source=footer>
.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/cde01e8d-8cbf-45a4-b689-61641ec58eb8%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/cde01e8d-8cbf-45a4-b689-61641ec58eb8%40googlegroups.com?utm_medium=email&utm_source=footer>
.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/8796292d-a071-449b-829b-696f4ddcf241%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/8796292d-a071-449b-829b-696f4ddcf241%40googlegroups.com?utm_medium=email&utm_source=footer>
.
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 [email protected].
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.
For more options, visit https://groups.google.com/d/optout.