Select different levels of layers for group (Export 3ds to Unity)

Hello,
Sorry for this simple question but I don't find a solution (and sorry for my poor english).
To keep my structure of 3ds Max layers when I export this scene to Unity, I do a group by layer. In Unity, I keep the structure.
But, with my script, I do a group with only the objects the objects on the same level.

I want to do a group with the object on the same level AND the sub levels.

For example:
Layer001 : box01 --> Group layer001 (box01)
Layer002 : box02 --> Group layer002 (Group layer03 + box02)
|layer 003 : box03 --> Group layer003 (box03)

Not esay to explain... :-)

My script :
---------------------------------------------------------------------------------
for i = 0 to layerManager.count-1 do
(
ilayer = layerManager.getLayer i
layerName = ilayer.name
(LayerManager.getLayerFromName layerName).current = true
(LayerManager.getLayerFromName layerName).select true
if selection.count > 0 then group $ name:layerName
)
---------------------------------------------------------------------------------
do you know how to include the sublevels ?
Thank you,
Frank

Comments

Comment viewing options

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

.

Try this:

(
	nestedLayersArr = #()
	function FindNestedLayersArr obj =
	(
		if classOf obj == MixinInterface do
		(
			append nestedLayersArr #(obj, obj.getParent())
		)
		numChilds = obj.getNumChildren()
		for layer = 1 to numChilds do FindnestedLayersArr (obj.getChild layer)
	)
 
	function GetObjectsInLayer layer: =
	(
		local objsArr
		layer.nodes &objsArr
		objsArr
	)
 
	for i = 0 to layerManager.count-1 where (layer = layerManager.getLayer i).getParent() == undefined do
	(
		nestedLayersArr = #()
		layerName = layer.name		
		FindNestedLayersArr layer
		allObjsArr = #()
		for i = 1 to nestedLayersArr.count do
		(
			objsInnLayerArr = GetObjectsInLayer layer:nestedLayersArr[i][1]
			join allObjsArr objsInnLayerArr
		)
		if allObjsArr.count != 0 do
		(
			group allObjsArr name:layerName
		)
	)
)

I don't have time to clean it. :)
If it puts all groups inside one main group just ungroup the top group.

frank_sdei's picture

Great !

Ok, thanks a lot, it's great !
Have a nice day,
Frank

Comment viewing options

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