PDA

View Full Version : script jobs and refrenced files.


calebros
11-26-2007, 05:56 PM
Hi,

Ok, so I have done some research but for the life of me I can not find the command to find out the namespace that is added to a file when it is refrenced.

For example,

I am trying to write a script job that will select multiple controls on a rig when it is a different control is selected. (much like the GUI retargeting done by ZooTriggered)

I basically want to concatenation the querryed string for the refrence file with a pre determined name (i have multiple indentically named rigs, and I would like to not have to hard code each rigs GUI).


On the other hand if there is a way to have a script job triggered by a specific object, that would work even better. currenctly the only way I can get it to trigger is a setup like this

scriptJob -ct "SomethingSelected" "proceedureThatChecksNames";

then I run that against a name checking proceedure and if it gets a possitive hit, then I forward the selection to the desired object.



I hope all this makes sense,

Anyways, Thanks for your help, and if you don't know off hand the answer, but you know of a resource that might have how to do this in it, I would love to be pointed that way.

-Steve



EDIT: oh, and I'm trying to do this in Mel and not python if that makes a difference. Thanks

katisss
11-30-2007, 08:47 AM
string $referenceFiles[] = `file -q -r`;
for ($i = 0; $i < size($referenceFiles); $i++)
{
string $rn = `file -q -rfn $referenceFiles[$i]`;
}

gives you the ref nodes for a start

scottiedoo
11-30-2007, 06:28 PM
I made something very similar and I can tell you a very easy way to do what you are trying to do regardless of reference namespaces.


You can create a "message" attribute on the controls and connect them to the other controls you want selected if that control is selected. You use a script job to run a script that goes through each of the message attributes and get the attached controls to select.

Whats great about message attributes is that even if you reference them or rename them, there is always a way to get the name without having to do any slicing and dicing of the reference or control names.

Just an idea that has worked for me.

If you still are set on stripping the namespace, I did write a procedure a while ago that based on a given object it will return the namespace, but you have to give it some strict keywords to separate the namespace cause sometimes some of my co-workers don't use namespaces when referencing so that uses just "_" rather than ":"

-Cheers,
scott

XAxis
12-17-2007, 04:21 PM
Hi there!

This is my first post in cgtalk! (Congrats to me, I guess...)


After a long night in front of my pc, trying to get the damned scriptJobs and expressions I wrote to run in a scene in which the character is imported twice - I finally succeeded, and thought I'd share my solution with you people and maybe help others by doing so.

So, like Calebros here - my approach was to break my selection name into two strings variables: one - which holds the namespace, and the other which holds the object name.

I actually had to write my expressions twice - once for a character with a namespace, and once for a character without one.

Ok, so this is what I did:

// get my selection's name into a string variable.

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

// here I check whether I have a colon in my selection's name. (If there's a colon in the selection's name - obviously it has a namespace!)

string $colonCheck = `match ":" $sel[0]`;

if ($colonCheck == ":") {

// here I break my selection name to two variables. $break[0] (before the colon) will contain the namespace, and $break[1] (after the colon) will contain the object name.

string $break[] = stringToStringArray ($sel[0] , ":");

// now I can enter whatever I want, and add the namespace to the objects that my expression relates to... Let's say:

setAttr ($break[0] + ":pSphere1.ty") ($break[0] + ":ctrl.sphereY");

}

// now I have to add an ELSE, which contains the same script, but without the namespaces. This is for the first character which doesn't get a namespace...

else {
setAttr pSphere1.ty ctrl.sphereY;
}

Ok, that's it I think. I hope I helped a bit. :wavey:

CGTalk Moderation
12-17-2007, 04:21 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.