So, I was having tons of trouble trying to set material ID's with an edit_poly modifier.
I looked at this forum and almost got my answer:
http://forums.cgsociety.org/archive/index.php/t-651273.html
Here is the solution:
--Step1: You must have the right mode and command panel settings before select command will work.
max modify mode
modPanel.setCurrentObject THE_CIL.modifiers[#Edit_Poly]
YOUROBJECT.modifiers[#Edit_Poly].SetEPolySelLevel #Face
--Step2: Now you can select
--Example1: Simple Select
YOUROBJECT.modifiers[#Edit_Poly].Select #Face #{1} --Select faces via bitarray
--Example2: Convert Array to bit array.
TheArray = #(1,2,3,4); --Numbers in array corrospond to faces to select.
--Could make this array in a do-loop.
BITarr = (TheArray as bitarray) --Convert normal array to bit array.
YOUROBJECT.modifiers[#Edit_Poly].Select #Face BITarr --Select faces via bitarray
--Sign:PolygonRunner
About Me
- PolygonRunner
- I do it all.
Saturday, June 5, 2010
Subscribe to:
Post Comments (Atom)
--Here is an example that I made.
ReplyDeleteJust run it and observe the material ID's of each cross section of the cylinder.
MAT_COUNT = 10;
SIDE_COUNT = 5;
THE_CIL = Cylinder();
THE_CIL.HeightSegs = MAT_COUNT;
THE_CIL.Sides = SIDE_COUNT;
THE_CIL.Height = MAT_COUNT * 10;
ep = Edit_Poly(); --create an Edit_Poly modifier
addModifier THE_CIL ep;
--//Before you add unwrap, apply the correct material IDs to the cylinder.
--Edit_Poly selection will not work unless you do the following 3 steps:
max modify mode --[1]
modPanel.setCurrentObject THE_CIL.modifiers[#Edit_Poly] --[2]
THE_CIL.modifiers[#Edit_Poly].SetEPolySelLevel #Face --[3]
for M = 1 to MAT_COUNT do(
FACEarr = #(); --//Face array is NEW array.
for S = 1 to SIDE_COUNT do(
Findex = ((M-1)*(SIDE_COUNT))+S;
FACEarr[S] =(Findex as integer); --Append to face selection.
)--Next S
--Create the new cross section selection.
BITarr = (FACEarr as Bitarray); --Turn array into bit array.
THE_CIL.modifiers[#Edit_Poly].Select #Face BITarr --Select faces via bitarray
--SET the material ID of your current selection.
--//http://forums.cgsociety.org/archive/index.php/t-651273.html
THE_CIL.modifiers[#Edit_Poly].SetOperation #SetMaterial
THE_CIL.modifiers[#Edit_Poly].MaterialIDtoSet = (M-1) --The SET is zero based.
THE_CIL.modifiers[#Edit_Poly].Commit ()
THE_CIL.modifiers[#Edit_Poly].SetSelection #Face #{} ;--Clear the selection so the next time you Select, it will not append the polygons from last time.
)--Next M
thanks man, good research here. helping out here! CHeers and keep it up
ReplyDelete