Selecting objects in a layer

I am currently trying my hand at MaxScripting and have currently pulled most of my hair out. I am trying to automate some of our processes. The script I want to write would do the following:

Select a Layer
Select all objects on that layer
Apply a material
Add a UVW Map to those objects.

And then repeat the steps for 3-4 layers

Any advice or direction would be greatly appreciated.

Thanks!

Comments

pcpyro's picture

Please excuse my lack of

Please excuse my lack of Maxscript knowledge...

So far I have come up with this:

macros.run "Layers" "LayerSelect"

$.material = meditMaterials[21]
macros.run "Modifiers" "Uvwmap"
$ [#UVW_Mapping].maptype = 4
$ [#UVW_Mapping].length = 120
$ [#UVW_Mapping].width = 120
$ [#UVW_Mapping].height = 120
modPanel.addModToSelection (VRayDisplacementMod ()) ui:on
$ [#VRayDisplacementMod].texmap = meditMaterials[21].texmap_displacement
$ [#VRayDisplacementMod].amount = 12
$ [#VRayDisplacementMod].shift = -6
$ [#VRayDisplacementMod].type = 0

I can't get his part to work because the UVW and Vray Displacement doesn't select an individual piece to apply the modifiers to. I will try to find something else out.

Also is there a way to get LayerManager to select a layer by name and not number? We have default layers that come in as Concrete and Asphalt, but they can end up being different numbers in the list depending on what the additional layers are named.

barigazy's picture

...

Hey guys use Forums section for discussion about code

bga

lrundlof's picture

I use this one (i shortened

I use this one (i shortened the list)

It reads from the material library "Mental.mat" then matches the layer name to a material name.

Im starting on your path to, to find a automatic UVW to layer name. If i find something ill let you know.

matlib = loadTempMaterialLibrary ((getDir #matlib)+"\\MENTAL.mat")
 
(
	local layersNameAndMatArr = #(#("HAGS-PL-Black", matLib["Plastic Black / NCS S 9005"]), \
		#("HPL-LightGray", matLib["HPL Grey light / NCS S 2500 N"]), \
		#("HAGS-PL-red", matLib["Plastic red carnaval / NCS 1580 Y90R"])	)		
 
	for i = 0 to LayerManager.count - 1 do
	(
		local layer = LayerManager.getLayer i
		for j = 1 to layersNameAndMatArr.count do
		(
			if matchPattern layer.name pattern:layersNameAndMatArr[j][1] do
			(
				local theNodes
				layer.nodes &theNodes
				theNodes.material = layersNameAndMatArr[j][2]
			)
		)
	)
)

without the code tags.