Querying namespace within ExpressionEditor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to write an expression on an asset that will be referenced into many different scene files.
I'm using an expression to run an offset on a transform attribute and I need to query it's own attributes
to achieve the desired effect. For efficiency, the expression needs to live in the asset file, not the file it's referenced into.
The short form of my request is how, if possible, can I query the namespace of the object inside it's own referenced expression?
string $ns = `referenceQuery -namespace $whatDoIPutHere`;
Longer explanation:
Here's a mock-up of the expression assinged to the object and attribute: "thisObject.thisAttr"
float $startTime = `playbackOptions -q -min`;
thisObject.thisAttr = thisObject.tx - (`getAttr -t $startTime thisObject.tx`);
if this object is referenced into a scene, Maya is smart enough to assign the namespace to some of the expression elements...
namespace = "ns"
The expression becomes:
float $startTime = `playbackOptions -q -min`;
ns:thisObject.thisAttr = ns:thisObject.tx - (`getAttr -t $startTime thisObject.tx`);
// Error: line 30: No object matches name: thisObject.offset //
The error is because Maya does not assign the namespace to queries inside ` `.
I would like to do this to solve the problem:
string $ns = [some code to query object(self)'s namespace]
if (size($ns)>0){$ns+=":" }
float $startTime = `playbackOptions -q -min`;
thisObject.thisAttr = thisObject.tx - (`getAttr -t $startTime ($ns+thisObject.tx) `);
So, back to my original question-- how, if possible, can I query the namespace of itself?
$ns = `referenceQuery -namespace $whatDoIPutHere`
The weird thing is that the expression actually evaluates correctly, despite giving the error message. Really I just want maya to stop giving the error message because it's doing the right math. Error messages freak people out. Animators and shot artists don't like error messages every time they do a time change.
Thanks for any assistance.