Select objects by layer

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  02 February 2010
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~
  02 February 2010
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: %\n" 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 = 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
				( = newName
				-- assign the material to the nodes
				theNodes.material = newMaterial

Online: LinkedIn
  04 April 2010
He didn't so I will.

Thanks Johan!!

  04 April 2010
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 09:39 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.