[Closed] Select objects by layer
Good Day,
I am VERY new to maxscript, my head is spinning and I feel like I’ve just been told that I have to climb mount everest.
I have just finished doing a search for every post that has anything to do with layers but couldnt find what I am looking for, so I am resorting to making a new post.
The place I am working for does architectural pre-viz and all of our models are crafted in Autocad Architecture and reference linked in 3dsmax for texturing and rendering. We use the same layering naming conventions in autocad all the time for each project.
What I am hoping for is a single script that has the ability in 3ds max to:
- Start at the top of the layers pallet and automatically select all objects on the first layer,
- ask for a new object(s) name per layer, and once given, rename all objects on that layer,
- then globally apply a pre-determined material to the objects in that layer
- then move down to the next layer and repeat until it gets through the last layer in the layers pallet.
For the most part, our texturing doesnt require the use of image files.
I hope I am not shooting for the stars with what seems to me to be a monster task.
Is there a way to do this through a script?
Alternatively, I would be happy if I could do the above tasks even for one layer through a script, as I could still make a toolbar that had each of our common layers names and get through the batch of them that way.
Thank you for your willingness to help out a maxscript noobie.
Sincerely, Douglas~
Hi Douglas,
Try this, it should get you a good head start:
(
-- pick a uniquename to transfer data from the rollout to the loop
global _layerNewPropsArr = #(undefined, undefined)
rollout nameMat "Name and Material"
(
edittext edtName "Name:"
materialbutton mbtMat "Material" width:80 height:30 across:2 align:#left
button btnDo "Next" width:50 height:30 align:#right
on btnDo pressed do
(
-- assign name and material to global variable
-- so we can pick it up after dialog is closed
_layerNewPropsArr = #(edtName.text, mbtMat.material)
-- pop the dialog
destroyDialog nameMat
)
)
-- loop over all the layers
for i = 0 to LayerManager.count - 1 do
(
-- get the layer by index
local layer = LayerManager.getLayer i
-- init a variable that will hold the layernodes
local theNodes
-- get the nodes
layer.nodes &theNodes
-- print to listener
format "name: %, nodes: %
" layer.name theNodes
-- create dialog to ask for layer properties
createDialog nameMat modal:true
-- the global array exists
if _layerNewPropsArr != undefined do
(
local newName = _layerNewPropsArr[1]
local newMaterial = _layerNewPropsArr[2]
-- check if a name was provided and it's not empty
if newName != undefined and newName != "" do
(
-- assign a uniquename based on the newName (adds 01 etc)
for n in theNodes do n.name = uniquename newName
)
-- check if a material was assigned
if newMaterial != undefined do
(
-- if a proper name was set rename the material to it.
if newName != undefined and newName != "" do
(
newMaterial.name = newName
)
-- assign the material to the nodes
theNodes.material = newMaterial
)
)
)
)
-Johan