|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Selecting Polygons by Material ID
|
|
|
Hi,
I’m working on a script which will run through a model and detach polygons based on the Material ID that is assigned to them.
macroscript Jeff category:"Dazza" (
on isEnabled return
(
selection.count == 1 and classOf selection[1].baseobject == Editable_Poly
)
on execute do
(
max modify mode
local obj = $
select obj
max modify mode
subobjectlevel = 4
obj.ButtonOp #SelectByMatID
)
)
So far my script is only looking to simply select the Polygons that have a certain material ID. My script seems to work, but only selects material ID 1. I need to know how I can change the Material ID it is selecting so it can loop through all the materials that are assigned to a model.
Max 2010 (SP1), Windows Vista 64bit
NVIDIA Quadro FX 1600M, 4GB RAM
|
|
|
|
This has to be some kind of record - 3 threads on detaching polys in 2 days… :-)
I really would stay away from “automated button pressing” if you can - straightforward scripting is much easier to deal with.
( local MatID = 1
while (polyop.getNumFaces $ > 0) do
(
$.selectByMaterial MatID
polyList = polyop.getFaceSelection $
if (polyList.count > 0) do
(
newName = (uniquename "DetachedObject")
polyOp.detachfaces $ polyList delete:true asnode:true name:newName
)
MatID += 1
)
)
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
Thanks Steve, does exactly what I needed it to do. Still getting my head around Maxscript. I’m trying to create a super script that will run through a whole scene, attach everything together, detach by mat id, add a uvw unwrap to each object, flatten uvws, then work out the surface area of the polys to prep for a lightmap, and hopefully automate all the lightmap renders so I can walk away.
I’ll no doubt be back soon when I get stuck on the next bit.
Thanks again,
Darren.
Max 2010 (SP1), Windows Vista 64bit
NVIDIA Quadro FX 1600M, 4GB RAM
|
|
|
|
|
Did you ever finish this superscipt? It’s what I need as well.
Author: IonDave
|
| Replied: 09 December 2009 08:31 AM
|
|
|
|
|
Bumped the wrong thread.
Max 2010 (SP1), Windows Vista 64bit
NVIDIA Quadro FX 1600M, 4GB RAM
|
|
|
|
|
|