
I wish you happy holidays!
Autodesk 3ds Max Tech Blog
Life is about learning, from your own experiences and from helpful people along the way. Everything from a 3d tip to larger topics such as composition and color theory, this is my area to give back to the graphics community.
While several lessons deal directly with 3ds Max, I've tried to keep discussions as software unspecific as possible, so you won't have to be a Max user to get something from these lessons.
for i in selection do (
c = snapshot i
c.transform = matrix3 1
d = dummy boxsize:(c.max - c.min)
delete c
d.transform = i.transform
d.pos = i.center
)
for i in selection do (
local c
with undo off ( c = snapshot i )
c.transform = matrix3 1
d = dummy boxsize:(c.max - c.min)
with undo off ( delete c )
d.transform = i.transform
d.pos = i.center
)
-- collect objects which has "height" property
objs = for o in objects where \
hasProperty o "height" collect o
-- collect Multimaterials from scene
MMats = for m in sceneMaterials where \
classOf m == Multimaterial collect m
-- filter array and collect integer values to a new array
oldArray = #("a", 12, "b", 3.5, 7)
newArray = for i in oldArray where \
classOf i == integer collect i
--> #(12, 7)
-- old and bad style coding (SLOW):
for o in Lights do
try(o.rgb = random black white)catch()
-- Optimized code:
for o in Lights where classOf o != TargetObject do
o.rgb = random black white
Basic script example
How to filter out shapes only in selection.
Collecting Photometric lights
Collect in array all photometric lights that are selected.
Remove specific type of object from scene
Delete all PF_Source in the scene.
Select objects with 0 vertices
How to exclude (delete or deselect) objects with 0 vertices (helpers objects).
-- collect 'em
g1 = $Bus_Controller_* as array
g2 = $Bus_Collider_* as array
g3 = $Bus_Graphic_* as array
-- LINK
for i=1 to g1.count do g2[i].parent = g3[i].parent = g1[i]
-- Quick Clay Render
with undo on
(
geo = for g in geometry collect g -- collect geometry
sha = for s in shapes collect s -- shapes as well
join geo sha -- join shapes
clay = standardMaterial diffuse:white shaderType:1
geo.material = clay -- assign mtl at Once (without loop)
sun = Skylight castShadows: true enabled: true
floorplane = plane lengthsegs:1 widthsegs:1 length:10000 width:10000
select geo
floorplane.pos.z = $.min.z -- easy Z align
floorplane.material = clay -- assign mtl to the plane
useEnvironmentmap = off -- turn off env.map
backgroundColor = white
renderers.current = Default_Scanline_Renderer()
max quick render
)
max undo
-- end