How to pick a group object?


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


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


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


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


do they work correct now?


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


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


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


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


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)) 


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


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*


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


What do you suggest I not uderstand?


just simple as:

iskindof node geometryclass and canconvertto node editable_mesh


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


nope… try again :wink:


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)


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
			append allObjParents obj
	FindRootParrent $Box001
	format "allObjParents: % 
" allObjParents


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:)