PDA

View Full Version : possible for expression to query its own name?


3dKris
09-26-2009, 04:00 PM
I have been trying to figure out if its possible for an expression (that gets run on scene open) to query the name of its own dependency graph node. The main trick here is that the name of the expression will change based on whether or not it is in the scene as a reference (also if there are more than 1, then obviously they will be followed by a number).

The reason for this is because the expression itself determines the location on disk of the scene file (if opened as a scene) or the reference file (if it is referenced). The expression needs to know if "it" (the expression) is itself a reference. Afterwords it passes the file path as argument to a UI script window that needs the folder path to find some Icon files that it uses. The end goal is to use this as part of a public rig, which is why its important to find the file path on scene open, rather that setting them as a constant variable in the script.

Any help is defiantly appreciated.
Thanks

Firas
09-27-2009, 09:58 AM
i have a solution for such case, is to assign a name for your expression, like "myScriptExp_onFileOpen"

then inside it, u can search for all node that have "*:myScriptExp_onFileOpen", and that will be your exp. node.


I'll post a small file that will have a script expression, and it will work on referencing .. its nice problem to solve.

just give me till end of day to find a free half an hour for that.

3dKris
09-27-2009, 12:35 PM
my only concern with that is if there are two characters in the scene (which will be referenced from the same .ma file presumably), then there will be two expressions of that name (with unique name spaces), and the script will not be able to tell which of the two (expression nodes) it actualy belongs to.

Firas
09-27-2009, 01:38 PM
give me 30min to send u an example .. I forget to till u one more step .. its to connect one of the objects in your scene to that script node..

in one hour i'll be free to send u the file..

Firas
09-27-2009, 03:49 PM
attached a simple maya file that has expression node, which will build an small UI to controls some objects.


u can refrence this scene multiple times and the expression will work fine.

(one small limitation, dont use nested referencing - i mean reference inside a reference - because that needs a small modification .. hope u can do it yourself)

its not the best method .. but it works :)

*edit...update file..v2

mlefevre
09-28-2009, 08:23 AM
Very cool Firas, thanks for sharing.

3dKris
09-28-2009, 11:14 AM
Hey thanks firas.
Only problem I am having is that I don't yet have maya 2009, so I can't acually open the file. While I attempt to get an upgrade, is there a way to explain what the expression does? does it provide a way to aquire the name of the expression node (or the name of any object that is part of the same reference). I am able to get a window to open no problem (even when referenced), the challange is finding the path (through referenceQuerey) so that the window can can automaticly load a hand full of icons (which will be located within the same folder as the .ma file, but the folder itself could appear anywhere on a users machine).

mlefevre
09-28-2009, 12:10 PM
3dKris, as it's an ASCII file (.ma) you should be able to open it up in a text editor and change any instance of 2009/2010 etc to your version of maya. (It'll only be the top 10 or so lines)

I'm running 8.5, so I changed every instance of 2010 to 8.5.

jaydru
09-28-2009, 01:18 PM
I'm running 8.5, so I changed every instance of 2010 to 8.5.

from 8.5 onwards theres an option in the open scene options window called "ignor version" saves having to edit those stupid version strings in the ascii

3dKris
09-28-2009, 01:20 PM
3dKris, as it's an ASCII file (.ma) you should be able to open it up in a text editor and change any instance of 2009/2010 etc to your version of maya. (It'll only be the top 10 or so lines)

I'm running 8.5, so I changed every instance of 2010 to 8.5.

Oh right, can't believe I didn't think of that.
Anyways, I have a look at the expression, and although its a little different from the way I am doing it (using a single window that is able to control multiple characters) I think I can still use the same principle as you did in your example. Thanks for the making the example, it was really helpful.

Firas
09-29-2009, 01:30 PM
u can use the attribute collection script (ac.mel)...it comes with the bonus tools..

i'll do my best this week to write small example ..

3dKris
09-29-2009, 07:51 PM
sounds interesting, no rush though, as I have it up and working for my character. But I have never heard of the attribute collection script, I would be interested to know what it does.

CGTalk Moderation
09-29-2009, 07:51 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.