View Full Version : Unable to get group name?
05-01-2008, 10:10 PM
After searching for a while I am still unable to find a way to get the currently selected group name. Since max just returns a list of objects in the group, $.name is invalid. I would just loop through to find the isGroupHead() but with nested groups, this is unreliable. I could do some trickery to find it but there has to be a simple way, right?
05-01-2008, 10:47 PM
Groups are basically dummy objects... There are a couple of ways you can look for a group... if there is a better way than what I am telling you now someone will correct me for sure, but this is how I use it in one of my scripts....
myGroups = for g in helpers where (isGroupmember g != True and classof g == Dummy) collect g
for X in myGroups do print X.name
This should do the job... If you use g = Objects instead of helpers it will give you the same result... obviously here if you have a dummy which is not a part of any group it will still be included in the results. But you can easily add some code to filter out unwanted scene objects and then run this code.
another way is what you mentioned>> isGrouphead. But i dont remember why i dont use it.
05-02-2008, 03:23 AM
holy crap, well that was my noob moment for the day :)
I actually just need to use:
for n in helpers do (
if n.isSelected == true then print n
it's been a long day
05-05-2008, 09:35 PM
That function would be problematic if you had a dummy in your group.
This is the function I use.
---- Find most senior group containing designated object ---
fn FindGroupHead obj =
if (isValidNode obj) then
obj = (obj as array)
if ((isGroupHead obj)AND(not (isGroupMember obj)))
then (return obj)
else (if (isGroupMember obj) then (FindGroupHead (obj.parent)) else (return undefined))
05-05-2008, 09:45 PM
Also if you just want to search the current selection:
fn FindGroupHeadinSelection objs =
for o in objs do
if (isgrouphead o) do return o
05-05-2008, 09:49 PM
The problem with the second function is if there is a neested group. You will dimply find the first group head which may not be the senior most grouphead. I'll check out the first one you posted :)
05-05-2008, 09:55 PM
Yeah I hate the way max handles groups all around. The isgroupmember + parenting is a nightmare when you want a group parented to an object.
So say you have a hand group parented to an arm which is in a body group. Grrrr!
The problem with the first one is that it finds the most senior group. I suppose you could add a filter... and find the most senior *selected* parent head by modifying the first function.
P.S. Give Ely Cannon my regards if you ever run into him down there. Although I'm not sure which Blizzard he's at.
05-05-2008, 11:16 PM
This returns an array of the top most group(s) selected...
function ReturnTopSelectedGroups = (
local SelGroupHeads =#()
local tnGroupHeads = for SelObj in selection where (isgrouphead SelObj) collect SelObj
for SelObj in tnGroupHeads do
if SelObj.parent == undefined then append SelGroupHeads SelObj
else if SelObj.Parent.isSelected == false then append SelGroupHeads SelObj
Of course as soon as you right something to work on one group, the artists want to select two or three thousand seven hundred and twenty three groups and do the same thing... hence the returned array... For a simple, single group closed and selected, just get the first item in the returned array.
As you can see it checks to see if it's at the top of the node tree, hence no parent, or does NOT have a selected parent above it.
05-05-2008, 11:49 PM
For a simple, single group closed and selected, just get the first item in the returned array.
Just a side comment: whatever you do: don't just grab (selection as array) that works about 98% of the time and will lead you to a sense of false security. :D Speaking from experience here.
05-05-2008, 11:49 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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.