Notifications
Clear all
[Closed] how to select layer from obj
Apr 21, 2010 1:36 pm
Hi all, I was wondering if it could be possible to select the containing layer once selected a particular obj in the scene. I don’t know if there’s a particular feature in max (2009)
4 Replies
1 Reply
see MXS help:
Interface: INodeLayerProperties (layer property)
Interface: LayerProperties (nodes method)
(
layerNodes = #()
theNode.layer.nodes &layerNodes
if theNode.isselected then select layerNodes else clearSelection()
)
-- select all nodes of the layer in any node in the layer is selected
fn selectAllNodesInLayer =
(
nodesToSelect = #()
layerNodes = #()
for node in selection where finditem nodesToSelect node == 0 do
(
node.layer.nodes &layerNodes
join nodesToSelect layerNodes
)
if nodesToSelect.count > 0 then select nodesToSelect else clearSelection()
)
Apr 21, 2010 1:36 pm
-- layer manager
L = layerManager
layerName_1 = "L1"
layerName_2 = "L2"
-- add new layer
L1 = L.newLayerFromName layerName_1
L2 = L.newLayerFromName layerName_2
-- open layer dialog
macros.run "Layers" "LayerManager"
-- add some nodes into your scene
c = circle name:(uniqueName "RotundaConstructio_") scale:[2,2,2] wirecolor:blue
rec = rectangle name:(uniqueName "Quadratum_") wirecolor:yellow width:20 length:20
-- sets layer´s name using nodes name
L1.setName (L1.name + "_" + c.name)
L2.setName (L2.name + "_" + rec.name)
-- add nodes to respective layer
L1.addNode c
L2.addNode rec
-- get nodes dependency
refs_D_Sphere = refs.dependsOn c
refs_D_Rec = refs.dependsOn rec
-- loop through dependencies and 'dirty' check the layer
for i = 1 to (refs_D_Sphere.count) do
(
print refs_D_Sphere[i]
print refs_D_Rec[i]
try
(
format "% % % %
" (refs_D_Rec[i].name) (refs_D_Sphere[i].name) (refs.DependentNodes refs_D_Rec[i]) (refs.DependentNodes refs_D_Sphere[i])
refs_D_Sphere[i].setName "{THIS_IS_THE_LAYER}"
)
catch(print "nop...")
) -- end for
hope that helps