View Full Version : How to create a new layer and add selected obj to the lay?
perfectboy 08-02-2009, 03:35 PM Maybe it doens't listen when do something in the layer panel for the Maxscript Listener...
But how to create a layer and add selecte obj to the it use script?
|
|
denisT
08-02-2009, 05:06 PM
Maybe it doens't listen when do something in the layer panel for the Maxscript Listener...
But how to create a layer and add selecte obj to the it use script?
check LayerManager Interface (LayerManager.newLayer()) and LayerProperties Interface (addnode) in MAXScript Help...
perfectboy
08-03-2009, 02:03 AM
Hi...nobody tell me? It have a diffcult for me to read the max help...
I think i can learn it by the script ...:curious:
denisT
08-03-2009, 02:36 AM
Hi...nobody tell me? It have a diffcult for me to read the max help...
I think i can learn it by the script ...:curious:
-- create new layer
layer = LayerManager.newLayer()
-- set layer's name
layer.setname "My Layer"
-- add nodes to layer from selection
for n in (selection as array) do layer.addnode n
perfectboy
08-03-2009, 03:08 AM
-- create new layer
layer = LayerManager.newLayer()
-- set layer's name
layer.setname "My Layer"
-- add nodes to layer from selection
for n in (selection as array) do layer.addnode n
Thanks and got that...
But how put objs which were selected in a array?
focomoso
08-03-2009, 03:38 AM
Did you try running the code? He did everything for you right there. "selection" is a built-in objectSet in max. It contains all the selected objects. "selection as array" casts it to an array (though technically you don't need to).
perfectboy
08-03-2009, 04:25 AM
Did you try running the code? He did everything for you right there. "selection" is a built-in objectSet in max. It contains all the selected objects. "selection as array" casts it to an array (though technically you don't need to).
Yeah, i tried...it's ok...
But it looks like just to add some objs in the new create layer,there're three layers , i don't konw how to add my selected objs to the layer i want...
focomoso
08-03-2009, 08:39 AM
Yeah, i tried...it's ok...
But it looks like just to add some objs in the new create layer,there're three layers , i don't konw how to add my selected objs to the layer i want...
Which is why he suggested you look at the layerManager in the help:
LayerManager.current : Interface : Read
Returns a LayerProperties MixinInterface to the current layer.
<Interface>LayerManager.getLayer <integer>which
Returns a LayerProperties MixinInterface to the indexed layer. The index is 0-based.
<Interface>LayerManager.getLayerFromName <string>name
Returns a LayerProperties MixinInterface to the layer with the given name.
perfectboy
08-03-2009, 02:09 PM
I want to add obj i selected to layer02,but it didn't work ,where it wrong ?
LayerManager.getLayerFromName "layer02"
<MixinInterface:LayerProperties>
for n in (selection as array) do layer.addnode n
-- Error occurred in n loop
-- Frame:
-- n: $Cylinder01
-- Runtime error: Attempt to access deleted <MixinInterface>
Polimeno
08-03-2009, 03:12 PM
I want to add obj i selected to layer02,but it didn't work ,where it wrong ?
LayerManager.getLayerFromName "layer02"
<MixinInterface:LayerProperties>
for n in (selection as array) do layer.addnode n
-- Error occurred in n loop
-- Frame:
-- n: $Cylinder01
-- Runtime error: Attempt to access deleted <MixinInterface>
you forgot to declare the variable, eg:
layer = LayerManager.getLayerFromName "layer02"
for n in (selection as array) do layer.addnode n
or
theLAYER = LayerManager.getLayerFromName "layer02"
for n in (selection as array) do theLAYER.addnode n
perfectboy
08-03-2009, 04:27 PM
...
[/CODE]
Yeah...Polimeno...
Thank you very much when i'm in trouble.
I Got That...
CGTalk Moderation
08-03-2009, 04:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.