hi
i want to know how i can identify if the selected objects are member of some group or group itself.
m using array of objects.
thnx
hi
i want to know how i can identify if the selected objects are member of some group or group itself.
m using array of objects.
thnx
Maya does not define term group or object just parent linkage, trasfroms and shapes. You could make a crude approximation but then youd still leave 2 normal maya occoureces into the darkness of night.
open up outliner and enable shape view and youll suddenly start to undrstand the problem. all "objects" are in all actuality a transform, shape pair:
CODE
transform -> shape
however what most calla group would be a
CODE
transform +-> transform -> shape
|
+-> transform -> shape
|
+-> transform -> shape
|
.
.
.
this however lacks something what if the tree stucture would be:
CODE
transform +-> shape
|
+-> shape
|
+-> shape
|
.
.
.
or what about
CODE
transform +-> shape
|
+-> shape
|
+-> transform- > shape
|
+-> transform- > shape
|
.
.
.
or
CODE
transform +-> shape
|
+-> shape
|
+-> transform -> transform +-> shape
| |
| +-> shape
|
.
.
.
so elementary one could say is a group is a transform that has just straforms as children, a parent linkage is a transform with child that has transforms under it. But it still leaves a lot of questions unanswered.
So in general speaking its best not to think in terms of objects or groups jsut transforms and shapes.
Hmm.. in one really able to construct such things? I just couldn't reproduce.
the parent command always creates another transform if you try to parent a shape under a transform that already has a shapenode!
And honestly in my 5 poor years of maya I haven't seen such a thing. OK, even If I just know about that transform -> shape construct 3 years ;]
I'd actually say you can assume that you have a group if its a transform with no shape-child.
And you have objects that are in a group if they are transforms that have no shape siblings.
so to finally find out that:
CODE
string $transformSel[] = ls -transforms -selection;
// Result: pPlane1 // < -- a planetransform is selected
size(listRelatives -shapes $transformSel);
// Result: 1 // < -- has a shape, in no group
string $transformSel[] = ls -transforms -selection;
// Result: null1 // < -- empty group transform is selected
size(listRelatives -shapes $transformSel);
// Result: 0 // < -- has no shape, in a group
Subdivs make such constructs when you go to proxy mode and so do some other things as well. Also i do it all the time especially usefully for bones.
Heres a example:
CODE
file -f -new;
sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;
move -r 1 0 0 nurbsSphere1.cv[0:6][0:7];
sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;
move -r -1 0 0 nurbsSphere2.cv[0:6][0:7];
parent -add -shape nurbsSphereShape2 nurbsSphere1;
delete nurbsSphere2;
If you didn't know of shapes you'd be looking at a impossible nubs surface. Certainly noramal users dont encounter this all that often but its still a possible case of confusion. Imjust pointing out that theres no such things as groups in maya.
So you actually cannot assume anything like that! best not to think in those terms. better think of it as a transform parenting.
PS you can add anything to there so you could have custom geometries for cameras etc! (by the way if you ever go and do look trough selected this is what happens!)
PPs you realy should pay more attention.
PPPS This was the first thing i noticed what i moved into using maya, if i hadent ditched the notion of groups i couldnt have continued on my way
okok I see. Multi-shapes under one transform is possible. But that whould not annul saying:
QUOTE(from me (I added some ""))
.. you can assume that you have a "group" if its a transform with no shape-child.
And you have "objects" that are in a "group" if they are transforms that have no shape siblings.
Right?
And the code I posted? I mean one can use something like that. We do so every day in production.
Joojaa, I'm creating this kind of structures
CODE
transform +-> shape*
|
+-> transform- > shape
|
+-> transform- > shape
where the one shape* directly under the main transform is used to display opengl code which visually groups the sibling transform nodes (well, the shapes that are on top of these transforms). Is it ok to do this or will this bring some kind of problems?
ewerybody, when you create dag nodes with the createNode command, you can specify in the -p flag the parent transform for the newly created shape. This way they don't create their own transforms and are immediately placed as children of the specified transform.
But, at least in 6.0.1 there is a bug in createNode, when you parent a dag node to a custom tranform node (MPxTranform) with the -p flag, the undo queue gets messed up as soon as you undo that node creation. This leads to crashes when doing a file -new.
no but the point is theres really no need to know whatever a thing is a group or not, if one chooses to think the thing differently then suddenly it contains no real meaningfully information. Either the parent linkage is there or not, its just another traversal thats all.
Daniel_Faust: i don't see why any hirerarchy would be less valid than any other.