PDA

View Full Version : multisub object mesh help!


maroooooo
05-08-2007, 02:56 PM
hi

i have found an old model that has loads of multisubobject materials on it. I need to select all the meshes in the file and detach all the faces that have opacity less than 100% and put them on a layer called see through. Is there any way of doing this.

kind regards

maroooooo

Zbuffer
05-09-2007, 10:02 AM
Hi,

Try this:
select all the objects you want, and evaluate the script
note: this will convert the object to Editable_Poly !


(
-- create the See through Layer
local l=LayerManager.newLayerFromName "see through"
-- collect the objects in the selection
local objs = for o in selection collect o
-- loop the collected objects
for obj in objs do
(
-- convert to Editable_Poly
if classof obj != Editable_Poly do convertTo obj Editable_Poly
-- get the Material
TheMat=obj.material

if classof TheMat==MultiMaterial do
(
-- collect transparent material IDs
local MatIDs=for i=1 to TheMat.numsubs where TheMat[i].opacity<100 collect i

local TheFaces=#()
-- collect the faces
for i=1 to obj.numfaces do
(
FaceID=polyOp.getFaceMatID obj i
if (finditem MatIDs FaceID)!=0 do append TheFaces i
)
-- build a new name for the faces to detach
local NewName=UniqueName (obj.name+"_see_through")
-- detach the Faces
polyop.detachFaces obj TheFaces delete:true asNode:true name:NewName
-- Move the new object to the see through layer
l.addnode (getNodeByName NewName)
)
)
)


Tested in Max9

maroooooo
05-09-2007, 04:16 PM
amazing


thank you

CGTalk Moderation
05-09-2007, 04:16 PM
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.