PDA

View Full Version : Problems assigning material to selected object.


Pixero
11-15-2006, 10:26 PM
Can someone see whats wrong with this? :shrug:


global proc js_objDepth()
{

// Create the shading nodes

//string $surfShade = `shadingNode -as surfaceShader`;

string $surfShade = `shadingNode -asShader surfaceShader`;

string $sg = `sets -renderable true -noSurfaceShader true -empty -name ($surfShade + "SG") `;

// Connect the material to the shading group

//defaultNavigation -connectToExisting -source $surfShade -destination $sg;

connectAttr -f ($surfShade + ".outColor") ($surfShade + "SG" + ".surfaceShader");



string $bwRamp = `shadingNode -at ramp`;

string $sInfo = `shadingNode -au samplerInfo`;

string $sRange = `shadingNode -au setRange`;

// Set the ramp colors

setAttr ($bwRamp + ".colorEntryList[0].position") 0;

setAttr ($bwRamp + ".colorEntryList[1].position") 1;

setAttr ($bwRamp + ".colorEntryList[0].color") 0 0 0;

setAttr ($bwRamp + ".colorEntryList[1].color") 1 1 1;

// Make the connections

connectAttr -f ($sInfo + ".pointObjY") ($sRange + ".valueY");

connectAttr -f ($sRange + ".outValueY") ($bwRamp + ".vCoord");

connectAttr -f ($bwRamp + ".outColor") ($surfShade + ".outColor");

//connectAttr -f ($surfShade + ".outColor") ($surfShade + "SG.surfaceShader");

// Connect the selected object. Just one object.

string $selectedObjects[] = `ls -sl`;

for( $obj in $selectedObjects)

{

connectAttr ($obj+ ".boundingBoxMinY") ($sRange + ".oldMinY");

connectAttr ($obj + ".boundingBoxMaxY") ($sRange + ".oldMaxY");

// Apply Shader to selected object. ------ I've tried all these.

// defaultNavigation -source $surfShade -destination |$obj|($obj + "Shape" + ".instObjGroups[0]") -connectToExisting;

// sets -e -forceElement $sg;

//hyperShade -assign $surfShade;

}

}

ajk48n
11-16-2006, 05:59 AM
You put your "string $selectedObjects[] = `ls -sl`;" statement after you make your shading nodes, so the node is automatically selected. Put the line in the beginning of the script, and it should be fine.

CGTalk Moderation
11-16-2006, 05:59 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.