Notifications
Clear all

[Closed] grops help please

Hi all

at the moment i am writing a script that collapses groups to editable meshes and want the mesh to be renamed as the original group name. However as far as i can see the groups dont have extension $.name therefore i cant save it in a variable and apply it to the mesh once it is collapsed. Can anyone think of a work around.

regards

Nebille

4 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Groups DO have a .name property.
Groups in Max are special case of hieararchy where the group is a Helper object and all grouped objects are linked (parented) to it. Just check for group head using the isGroupHead method and grab the name of the helper – that will be the name of the group…
Unless I am misunderstanding what you are doing…

cheers bobo i will give it a go now

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Here is a simple example:


theGroups = for o in helpers where isGroupHead o collect o --collect all groups in the scene
for g in theGroups do --for each group
(
	theChildren = g.children --get its children
	--filter out the geometry objects from the group's children
    theGeometry = for o in theChildren where superclassof o == GeometryClass and classof o != TargetObject collect o
	if theGeometry.count > 0 do --if there are any geometry objects
	(
		convertToMesh theGeometry[1] --convert the first one to a mesh
		for c = 2 to theGeometry.count do --go through the rest, if any
    		attach theGeometry[1] theGeometry[c] --and attach them to the first mesh
		theGeometry[1].name = g.name --set the name of the final mesh to the group's name
		ungroup g --ungroup the group
	)--end if	
)--end g loop

thanks bobo you are a true legend