Notifications
Clear all
[Closed] Select Children of nested layers?
Dec 27, 2016 6:35 pm
Hello, did someone know how to select all nested childs of a layer named “Clones” (objects ,helpers… and childs objs of nested layers…= nodes?), to rename all of them with a prefix?
there’s no way to select a layer by name and have an equivalent of: macros.run “Scene Explorer” “SESelectChildren” ?
By avance, thanks
for i = 0 to (layermanager.count - 1) do
(
x = layermanager.getlayer i
layername = x.name as string
if (matchPattern layername pattern:"Clones") do
(
layerRT = x.layerAsRefTarg --get layer as RefTarget
refs.dependents layerRT --see the dependents
layerRT.getNumChildren()
if (childLayersCnt = x.getNumChildren()) != 0 do
(
for j = 1 to childLayersCnt do
(
y = (x.getChild j)
y.name = "Old_" + y.name
)
)
)
)
2 Replies
Dec 27, 2016 6:35 pm
This will rename all objects in all nested layers in the layer with the name “Clones”
(
nestedLayersArr = #()
function GetObjectsInLayer layer: =
(
local objsArr
layer.nodes &objsArr
-- return the objects
objsArr
)
function FindnestedLayersArr obj =
(
if classOf obj == MixinInterface do
(
append nestedLayersArr obj
)
numChilds = obj.getNumChildren()
for layer = 1 to numChilds do FindnestedLayersArr (obj.getChild layer)
)
-- "get the main layer"
mainLayerName = "Clones"
mainLayer = LayerManager.getLayerFromName mainLayerName
-- "find all nested layers"
FindnestedLayersArr mainLayer
-- "rename the objects"
for nLayer in nestedLayersArr do
(
objsInnLayerArr = GetObjectsInLayer layer:nLayer
for o in objsInnLayerArr do
(
o.name = "Old_" + o.name
)
)
)
Shorter version:
(
function GetObjectsInLayer layer: =
(
local objsArr
layer.nodes &objsArr
-- return the objects
objsArr
)
function FindnestedLayersArr obj =
(
if classOf obj == MixinInterface do
(
objsInnLayerArr = GetObjectsInLayer layer:obj
for o in objsInnLayerArr do
(
o.name = "Old_" + o.name
)
)
numChilds = obj.getNumChildren()
for layer = 1 to numChilds do FindnestedLayersArr (obj.getChild layer)
)
-- "get the main layer"
mainLayerName = "Clones"
mainLayer = LayerManager.getLayerFromName mainLayerName
-- "find all nested layers and rename the objects"
FindnestedLayersArr mainLayer
)