PDA

View Full Version : Script executing problem


fr3drik
11-19-2003, 09:22 AM
I have a script (filename faSubdPolyToggle.mel) that looks like this:


global proc faSubdPolyToggle ()
{


// SELECT CURRENT SUBD TRANSFORM NODE(S)
select -hi;
for ($item in `ls -sl -type "transform"`)
{

// ADD ATTRIBUTE highres
print ("addAttr -ln highres -at bool -dv off " + $item + ";");
print "\r";
print ("setAttr -e -keyable true " + $item + ".highres;");
print "\r";

// ADD ATTRIBUTE lowres
print ("addAttr -ln lowres -at bool -dv on " + $item + ";");
print "\r";
print ("setAttr -e -keyable true " + $item + ".lowres;");
print "\r";

// CONNECTIONS
print ("connectAttr -f " + $item + ".highres " + $item + "Shape.visibility;");
print "\r";
print ("subdGivenIntoPolyMode " + $item + "Shape 1 0 0 0;"); //NEEDS FOR ShapeHistPoly ATTRIBUTE TO BE CREATED
print "\r";
print ("connectAttr -f " + $item + ".lowres " + $item + "ShapeHistPoly.visibility;");
print "\r";

}

}


When I type faSubdPolyToggle; into the command line this code appears in the script editor's history:


faSubdPolyToggle;
addAttr -ln highres -at bool -dv off subdivCube1;
setAttr -e -keyable true subdivCube1.highres;
addAttr -ln lowres -at bool -dv on subdivCube1;
setAttr -e -keyable true subdivCube1.lowres;
connectAttr -f subdivCube1.highres subdivCube1Shape.visibility;
subdGivenIntoPolyMode subdivCube1Shape 1 0 0 0;
connectAttr -f subdivCube1.lowres subdivCube1ShapeHistPoly.visibility;


...but it isn't executed! I need to copy this text into the script editor and manually execute it to make it work.

What am I doing wrong?! :cry:

misterdi
11-19-2003, 09:44 AM
Your script actually is only printing the command, not to execute it.

If you want it to be print and executed, maybe you should put your command string into a string variable, then you can issue eval and print command.

fr3drik
11-19-2003, 10:20 AM
Thanks, it's now working great using the eval command instead :)

CGTalk Moderation
01-16-2006, 05:00 PM
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.