# How to pick a group object?

#21

Wow Denis. I never doupted that your solution will not be the best.
First time I see theses two methods getRootGroupHead and getGeometryGroupMembers .
MXS HELP not have explained theses badass methods?

#22

THESE ARE MY FUNCTIONS!!! ha-ha… you have to write your own. that what i was asking you

#23

do you know how many geometry classes in standard max system are not really geometries?
11 (you check only 1 - TargetObject)

so you need another function to do - isRealGeometry

#24

Now you could have fooled me
I already wrote my but … :). Anyway thanks. This was fun.

#25

do they work correct now?

#26

btw… all three my functions are only one line of code… so they are simple if you know what to do

#27

here is improved test:

``````
delete objects
(
b0 = box pos:[40,0,0] wirecolor:orange
b1 = box pos:[80,0,0] wirecolor:orange
sn = snow()

g0 = group #(b0,b1,sn)

b2 = box pos:[40,40,0] wirecolor:green
b3 = box pos:[80,40,0] wirecolor:green
mr = mr_Proxy pos:[0,40,0]

g1 = group #(b2,b3,mr)
g2 = group #(g0,g1)

in (box pos:[0,0,40] wirecolor:blue) (g2.parent = box pos:[0,0,80] wirecolor:red)
for g in #(g0,g1,g2) do setGroupOpen g on
)

``````

#28

Can I use this to find out isRealGeomtry?(I add only two classes for check)

``````
for o in geometry where canConvertTo o editable_mesh and canConvertTo o editable_poly collect o
``````

#29

that’s the right idea… but it’s absolutely enough to check only conversion to editable_mesh
search in geometry is too long… there is a better way

#30

Can you tell me why:
> this works

``````
b0 = box pos:[40,0,0] wirecolor:orange
b1 = box pos:[80,0,0] wirecolor:orange
in (g0 = group #(b0,b1)) (box pos:[0,0,40] wirecolor:blue)

``````

and this not

``````
b0 = box pos:[40,0,0] wirecolor:orange
b1 = box pos:[80,0,0] wirecolor:orange
in (box pos:[0,0,40] wirecolor:blue) (g0 = group #(b0,b1))
``````

#31

there is an eternal bug in group messaging system… it sends some sort of a delayed message… so in the second snippet system doesn’t link group to box because group “is not created” at that time

#32

That is useful info. Thanks.
So to return to the isRealGeometry topic.
You told me that is ":“search in geometry is too long… there is a better way
The only way that i know is selection or objects.
Maybe we can select all groups usring helpers
If we named groups correctly then you can use \$Group* or \$objects/group*

#33

you don’t have to search at all to know that the node is geometryclass…

#34

What do you suggest I not uderstand?

#35

just simple as:

``````
iskindof node geometryclass and canconvertto node editable_mesh

``````

#36

Ok you talking about “pickObject” node. Now I get it.
I supose that I need to check if group is opened, right?

#37

nope… try again

#38

This freeze max, i not know why

``````
fn getGrandParentGroup obj =
(
groupsArr = #()
while (obj.parent != undefined) do (if isGroupHead (grp=obj.parent) do append groupsArr grp)
groupsArr[groupsArr.count]
)
``````

#39

Branko, this is infinite while loop. The obj never changes, so its parent never changes and the max continue to execute the while loop.

The function below will return all parents of the selected object. So, for the test scene it will return \$Box005. Then can be checked which object in the allObjParents are group head or group member.

``````
(
(
local allObjParents = #()
function FindRootParrent obj =
(
parent = obj.parent
if parent != undefined then
(
append allObjParents obj
FindRootParrent parent
)
else
(
append allObjParents obj
obj
)
--
objParents
)
FindRootParrent \$Box001
format "allObjParents: %
" allObjParents
)
``````

#40

I know how to find all parents but are you try to find root group in Denis example (“Group003”). He mentioned one line of code for that:)