How to make Expressions work in referenced scenes?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2013
It really is a bit rediculous that you can't just query an object's namespace.

For the current project, im pretty happy to just ignore the string prefix, we always use namespaces with colons anyway.

Thanks for all the input guys.

If anyone does have any other bright ideas, let me know.


Edit: I found this little tidbit in the Maya Command Reference about the referenceQuery command, which should be able to give you the parent namespace of an object.

However, when I run the test script at the bottom of the page and then run the following command:
referenceQuery -parentNamespace mid:botRN;

It should return the object's namespace, but instead I get the following error:

Error: line 0: Invalid flag '-parentNamespace' // 


It doesn't work in Python either.

There was a mention of it only being added in Maya 6.5 but im running 2011.5x64

Anyone know?

Last edited by Taunise : 01 January 2013 at 02:44 AM.
 
  01 January 2013
There is just this one tiny problem you're gonna face after you get this working - you can't lock attributes in a referenced node

Anyway, to get this thing working (that is, until I've hit the brick wall above), I used a uniquely named script node (just put a random generated prefix to it), then use messages to navigate from script node to sphere. I could not successfully use "node" procedure in 2011 to get script node name, like was suggested, but that would simplify things further, if you could get it working.

This one prepares our scene - just for testing;

global proc setupScene(){
    $sphere = `sphere`;
    addAttr -at "float" -keyable 1 -ln "followingHead" $sphere[0];
    
    $scriptNode = `scriptNode -st 1 -name "lockUnlockAttributesScriptNode_2987235183098551876  4563897"`;
    addAttr -at "message" -ln "sphereLink" $scriptNode;
    connectAttr ($sphere[0]+".message") ($scriptNode+".sphereLink");
}

setupScene();


this is the actual expression (please note that spaces in node name are added by cgtalk.com)

global proc string getSphereName() {
	$name=`ls -recursive 1 lockUnlockAttributesScriptNode_2987235183098551876  4563897`;
	$sphere = `listConnections ($name[0]+".sphereLink")`;
	return $sphere[0];
}

global proc warn(){
	$sphere = getSphereName();
	float $followingHead = `getAttr ($sphere+".followingHead")`;
	$lock = $followingHead == 1;
	setAttr -lock $lock ($sphere+".translate");
}

global proc installScriptJob(){
	$sphere = getSphereName();
	scriptJob -attributeChange ($sphere+".followingHead") warn;
}

installScriptJob();
__________________
Victor
ngskintools.com - skinning plugin for Autodesk Maya
 
  01 January 2013
Originally Posted by uiron: I could not successfully use "node" procedure


It's a little weird.. when I originally heard about this I believe it returned the full path including namespace.. but now in 2012 it appears that expressions work inside their namespace and you don't even need to know the namespace to use setAttr or getAttr? Anyway I don't know if I have access to older version of maya where I could test his.
__________________
blah blah blah

Last edited by gmask : 01 January 2013 at 10:29 PM.
 
  01 January 2013
I've tried calling
$nodeName = node;


..but it did not work in 2011 maya.
__________________
Victor
ngskintools.com - skinning plugin for Autodesk Maya
 
  01 January 2013
Originally Posted by uiron: I've tried calling
$nodeName = node;


..but it did not work in 2011 maya.


Hmm .. when you say it does not work.. do you mean you get an error or you don't get the results you were expecting?

Actually this is not working as I recall it working.. it's just returning the name of the referenced expression without the name space which is not helpful.
__________________
blah blah blah

Last edited by gmask : 01 January 2013 at 06:16 PM.
 
  01 January 2013
Try this..

create an expression..

add this to the expression..

namespace -set ":";
string $node=node;
print("$node="+$node+"\n");


Then reference this scene with a namespace and it should print the name of the expression with the namespace. From there you can extract the namespace however you like and proceed from there.
__________________
blah blah blah

Last edited by gmask : 01 January 2013 at 09:23 PM.
 
  01 January 2013
It appears that expressions by default will run inside their namespace so you can also put this in an expression..

string $ns=`namespaceInfo -cur`;

print($ns+"\n");

I'm starting to think they must have fixed something in a recent version.
__________________
blah blah blah

Last edited by gmask : 01 January 2013 at 10:10 PM.
 
  01 January 2013
Originally Posted by uiron: ..but it did not work in 2011 maya.


Okay was able to test several of the methods I've mentioned and they all worked in 2011.5.. and above.. I couldn't test in 2011.

I created scenes that had the following expressions.. saved the scene and then referenced them into a new scene

namespace -set ":";
string $node=node;
print("$node="+$node+"\n");

worked..

string $ns=`namespaceInfo -cur`;
print($ns+"\n");

worked..

float $x=sin(frame);
setAttr pSphere1.translateX $x;
float $tx=`getAttr pSphere1.translateX`;
print($tx+"\n");

also worked.. and you don't even need to know the namespace.. it just assume you mean the sphere inside the namespace of the referenced scene... which is how this should have worked all along.

I assume somewhere between 2009 and 2011 this was fixed.
__________________
blah blah blah
 
  01 January 2013
Are these methods not working for anybody but me? Uiron?
__________________
blah blah blah
 
  01 January 2013
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:15 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.