PDA

View Full Version : Scripting and hierarchy and naming approaches


tymznd
03-21-2003, 01:09 AM
Hopfully Jason is out there somewhere as his DVD stirred some thoughts...

I am writing a script that is attaching a face rig. The face rig consists of wire deformers and therefore splines and sets. I have been struggling with how to optimally name objects/parent objects/create custom attributes/create nodes?? in order to facilitate proper scanning and processing of the structure.

The workflow is somthing like this:
1 - select pts on the face geometry
2 - run a script that creates a set for that selection, and create a curve using the selected points
3 - select the curves that were previously created that will make up the wire def.
4 - run a script that selects the sets for each curve, group them (for organizational purposes), create wire deformers, group the control wires.
5 - create expressions to drive the envelope of the wire def.

Now I want to mirror this setup:
The only way that I have come up with re-creating sets for a subDMirror is to first select the level 0 pts, and then use the refineselection command to scan the lower level pts of the subD, in order to re-create the sets. (Any easier thoughts on how else to do this are welcome)... so I need to be able to get all the pts on a certain level, organized by sets.

ONTO THE QUESTIONS:
1 - I can't decide if it is best to name things what they actually are, or leave that to the relative parenting... for example.
L_eye_corner_upper_level_2_set
L_eye_corner_upper_level_3_set
R_eye_corner_lower_level_2_set
vs something like.
L_sets|eyes|corner|level2|upper_sets
L_sets|eyes|corner|level2|lower|set
R_sets|eyes|corner|upper|level2|set1

In the above, trying to identify the upper vs. lower in context of the L vs. R could be tricky. But the second example forces you to identify the hier when trying to "select set1"... and also implies parenting relationships that may not be right.

2. How do you guys typically scan through sets that can contain sets and have no defined depth(meaning set within set within set within???) ? I mean I can create the loop... thats not my issue.... my issue is that if I want to get all the level "2" sets.... then I first have to get all the sets, token them, scan for the "2", and rebuild the list.

3. Do you guys simply create custom attributes to do this type stuff. Like say a node or attribute that contains a list of all sets for a given geometry?

mark_wilkins
03-21-2003, 03:14 AM
1) By naming with underscores, you can find all the nodes in a given category easily. For example, get all the eye nodes with

string $eye_nodes[] = `ls "*eye*"`;

2) Same thing. Don't tokenize, just do this:

string $level_2[] = `ls "*_level_2_set"`;

3) You can do that, although I'd probably just list the connections and find the sets in the list.


-- Mark

tymznd
03-21-2003, 06:41 AM
:eek:
wow, I never even thought of that.... thank you very much for opening my *eyes*.;)

Now for the stupid question.... I see a ton stuff when I do a basic "ls", it seems to span outside of my current file? I assume that these are shared nodes... is that correct? are they determined by the current "project"... and where do these nodes live?

Where do you store arrays of information that you want to be saved with the file? Is there like a generic array node to just hold whatever?

Am I missing help docs that cover all this?

mark_wilkins
03-21-2003, 06:49 AM
Where do you store arrays of information that you want to be saved with the file? Is there like a generic array node to just hold whatever?

You have a couple of options.

You can use an option variable (look up the optionVar command) or you can create a node with custom attributes to hold what you want. The latter probably works better in expressions.

I recommend putting custom attributes on existing nodes where it makes sense, but if you really wanted something like a list of stuff saved in your scene you could always make a node of type "unknown" by doing this. Don't do this in an expression; instead have a MEL script that sets it up beforehand and point your scripts at its attributes:

string $node_name = `createNode unknown -name dataNode1`;

Remember that when you create a node you should always check the return value in case Maya assigned you a different name than you'd asked for, which can happen.

As for why ls returns all those items, many of them are hidden from view by default but still exist in your scene. These are generally called "underworld" nodes.

-- Mark

tymznd
03-21-2003, 10:58 PM
but if you really wanted something like a list of stuff saved in your scene you could always make a node of type "unknown" by doing this.

Thanks... and so then I can create my own custom attributes.... where do you usually put lists of stuff?

In the Add Attr window there is the "Attribute Type" but the "Per Particle (Array)" is greyed out?? Is this where you would store strings lists? and if so, how do I un-grey it:)

mark_wilkins
03-21-2003, 11:37 PM
You should be able to make arrays with the MEL command addAttr -dt <array type>. Look in the addAttr documentation.

Per particle attributes are different and only apply to particle objects, which is why it's grayed out.

-- Mark

tymznd
03-22-2003, 11:30 PM
Mark

Thanks for all of your input. :thumbsup: I have spent the last day going through the docs and reading up on the dev stuff and learning a little about the underworld, etc... The optionVar is really cool to know about as well.

Here is where I am stuck:

select -r one ;
addAttr -ln arrayz -dt stringArray;
setAttr one.arrayz -type stringArray 3 "link1" "two" "th_3";
getAttr one.arrayz;
// Error: The data is not a numeric or string value, and cannot be displayed. //
getAttr -type one.arrayz;
// Result: stringArray //
string $xx[] = `getAttr one.arrayz`;
// Error: The data is not a numeric or string value, and cannot be displayed. //
// Result: //
$test = `getAttr one.arrayz`;
// Error: The data is not a numeric or string value, and cannot be displayed. //
// Result: //


How do I getAttr in order to retrieve the array?

CGTalk Moderation
01-14-2006, 06:00 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.