Hierarchy to layer
Hello,
I'm try to make script that transform a hierarchy like :
dummy01
dummy02
object01
object02
.....
dummy03
object03
.....
to
layerA
layerB
object01
object02
.....
LayerB
object03
.....
don't when I try to put object into layer I've got an error like
-- [stack level: 1]
-- called from o loop; filename: C:\Users\charles\Downloads\hierarchy_to_layer.ms; position: 1630; line: 74
-- Parameters:
-- o: $Dummy:carre @ [-4.860891,11.906838,0.000000]
-- Locals:
-- o: $Dummy:carre @ [-4.860891,11.906838,0.000000]
-- enfant: #($Box:Box002 @ [11.277443,7.361247,0.000000], $Box:Box001 @ [-19.488970,3.360549,0.000000])
-- Externals:
-- collectMyChildren: Global:collectMyChildren : collectMyChildren()
-- layer: Global:layer : undefined
-- owner: undefined
-- ------------------------------------------------------
-- [stack level: 2]
-- called from top-level
Here a part of the code
for o in ParentUnique do (
layer = LayerManager.newLayerFromName o.name
enfant = collectMyChildren o includeParent:false as array
-- format "layer:%, enfant:% \n" o.name enfant
for e in enfant where ( superclassof e == GeometryClass ) do (
layer.addnode e
format "layer:%, enfant:% \n" o.name e.name
)
)
"layer.addnode e" seem to cause the error.
Thancks in advance for your help.
Ps : the goal is to organize 3dsmax scene get from fbx file import from rhino.
Comments
.
I have tested the code with a scena that I created(sphere linked to sphere linked to dummy linked to dummy) but there are no problems.
Can you share a scene and the whole code that gives you the error?
Tools and Scripts for Autodesk 3dsMax
.
Can you show the full code or at least what the collectMyChildren function returns as colletion of objects?
Tools and Scripts for Autodesk 3dsMax
Here the code for
Here the code for collectMyChildren, I'm not the autor of this part (what why it's seem to be well coded !)
fn collectMyChildren obj includeParent:true =
(
-- start collecting direct children of
myChildren = #(obj)
-- add children and their children etc recursively
i = 0
while i < myChildren.count do
(
i += 1
join myChildren myChildren[i].children
)
-- remove initial object if == false
if not includeParent then deleteitem myChildren 1
-- return array containing children
myChildren
)