Script node error...

Script node error...

ShreddinPB
Contributor Contributor
1,451 Views
6 Replies
Message 1 of 7

Script node error...

ShreddinPB
Contributor
Contributor

Hey guys, I am having some trouble with a script node and expression combination and I cant figure out what is wrong. I have two different script nodes for the test. They both do the same thing, one in python and one in mel. They are both set to execute on open, basically creating a function I can call.

As a note, in both expressions I have

locator1.translateY = pythonSphere.testEnum;

The expression wouldnt update correctly it seemed if I didnt have it directly connected to some other objects attribute.

 

the python one:

 

def printEnum(theObject):
	switchTo = cmds.getAttr(theObject+'.testEnum', asString = True)
	print switchTo

the python expression:

locator1.translateY = pythonSphere.testEnum;
python("printEnum('pythonSphere')");

If I change the enum attr I get an error.

#   File "<maya console>", line 2, in printEnum
# TypeError: Flag 'asString' must be passed a boolean argument // 

However if I just run the function like this.

printEnum('pythonSphere')

it prints the enum as expected, so the function actually works. It only seems to not work if I try to call the function from the expresssion because if I run it exactly as it is thru a mel tab like so

python("printEnum('pythonSphere')");

It STILL works!! It just doesnt work if that is called from an expression and errors out the funciton.

 

the mel one:

 

 

global proc printEnumMel(string $theObject){
string $testFor = $theObject+".testEnum";
string $spaceSwitcher = `getAttr -asString $testFor`;
print $spaceSwitcher;}

the mel expression:

locator1.translateX = melSphere.testEnum;
printEnumMel "melSphere";

The mel one works as expected. If you change the enum attr it prints what the enum is set to.

 

Any ideas what is going on? Is this a bug?

I know extressions are not really mel, but I feel if I can run the function it is trying to run it should still work.

 

 The file is attached here. You should be able to just load the scene and change the attrs on the spheres and see what is going on.

 

 

0 Likes
1,452 Views
6 Replies
Replies (6)
Message 2 of 7

cheng_xi_li
Autodesk Support
Autodesk Support

Hi ShreddinPB,

 

I've tested your scene. It looks like a bug. Using DG instead of parallel or serial evaluation would be better(almost no error).

 

I have logged this as defect in our system.

 

Yours,

Li

0 Likes
Message 3 of 7

ShreddinPB
Contributor
Contributor
Where do I go to set that setting? I dont see it on the script nodes or in the expression editor.
thanks!
0 Likes
Message 4 of 7

cheng_xi_li
Autodesk Support
Autodesk Support

It is in the preference settings.

 

EvaluationMode.png

0 Likes
Message 5 of 7

gavinthomas89
Community Visitor
Community Visitor

Hey, this looks like it is still a problem.

 

If you create a polyCube

 

 

from maya import cmds
cmds.polyCube()

 

 

 

Then run the code:

 

 

script_node = cmds.scriptNode(
    name="test_scriptNode",
    scriptType=7,  # Time changed.
    beforeScript="cmds.select('pCube1.f[0]')",
    sourceType="python",
    ignoreReferenceEdits=True,
)

 

 

 

 

In DG it works as expected but in Parallel it errors:

 

 

# ValueError: No object matches name: pCube1.f[0] # 

 

 

Doesn't matter if it's written in mel or python. 

 

0 Likes
Message 6 of 7

mcw0
Advisor
Advisor

I wonder if putting a "refresh" after the cube creation would help

0 Likes
Message 7 of 7

gavinthomas89
Community Visitor
Community Visitor
The cube was created in the scene without a script. So refresh doesn't
achieve anything.
0 Likes