Replace a group (and its child objects) with another group (and its child objects)

I'm trying to write a scene optimisation script that swaps out groups in the scene with groups from an external .max file.

So far my script does this:
1. Collect the groups in my scene as an array (called originalgroups).
2. Import new groups from an external .max file (but only import groups that match the names in originalgroups array)
3. Create a second array containing the imported groups (called newgroups)

For the last step,
How do I replace a group node and all it's child objects with another group and all it's child objects?

Any help would be awesome thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
id_ivan's picture

-

Dunno what method you use to collect old and new groups, but the abstract is like:
1. Get old group transform.
2. Delete old group
3. copy old transform to new group.

(
	oldGroup = #("Group001")
	newGroup = #("Group002")
	for g=1 to oldGroup.count do (
		oriT = (og = getnodeByName oldGroup[g]).transform
		delete og
		(ng = getnodeByName newGroup[g]).transform = oriT
	)
)

Rivanoor Bren
https://rivanoor.info

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.