PDA

View Full Version : Split Faces of Edit_Poly by mult-sub ID ?


Polimeno
02-08-2009, 12:28 AM
i have a character´s hand with 15 bones (hand, thumb1, thumb2, index1...etc...).

i did a simple MXS to automaticly put a multi-sub Object (15 IDs) with random colors to the mesh, and clone as a proxy.... ok.

so now,
how to split/detach each section ID ?
how to calculate the nearest bone to use its name on the detached element ? volume, area, bouding box ??

i´m kinda lost ......


ps:
attached the scene ( Max 9) + script (doesn´t working)


thanks in advance

Polimeno
02-11-2009, 07:15 PM
Mat_multSub = Multimaterial ()
meditMaterials[1] = Mat_MultSub
theObj = $sphere
theObj.material = Mat_multSub

Mat_multSub.name = "Split_Face_by_ID"
Mat_multSub.materialIDList = #(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)

for i = 1 to (Mat_multSub.material.count) do
(
Index = i as string
Mat_multSub.material[i].name = "faces_" + Index
meditMat = meditMaterials
MagentaC = color 255 0 120
GreenC = [0, 220, 155] as color
RandomColor = (random MagentaC GreenC)
meditMat[1].material1.diffuse = RandomColor
meditMaterials[1].materialList[i].diffuse = RandomColor
)


theClone = copy theObj wirecolor:yellow prefix:"proxy_"
convertToPoly (theClone)

NumFaces = polyOp.getNumFaces theClone
for i = 1 to (NumFaces) do
(
IDs = polyOp.getFaceMatID theClone i
print (IDs)
)
FaceID = theClone.selectByMaterial 4

------------------------ PROBLEM
detach_Faces = polyOp.detachFaces theClone #{FaceID} name:"test_1"
------------------------ PROBLEM

--polyOp.setFaceSelection theObj #(1,2,3,4)
--theObj.sepByMats 1
--theObj.separateByMaterial = false

Polimeno
02-13-2009, 10:57 PM
Anyone ?



please...help.

galagast
02-14-2009, 06:33 AM
The line:
FaceID = theClone.selectByMaterial 4
returns a value "OK"
In effect, you're storing the value "OK" to the variable FaceID..

so when the script executes the problem line:
detach_Faces = polyOp.detachFaces theClone #{FaceID} name:"test_1"
you get an error, because #{FaceID} is essentially #{OK} which wouldnt make sense for the polyOp.detachFaces method.

you need to look for a function in the helpfile which would return to you the selected faces of the poly.. something like this.
FaceID = theClone.selectByMaterial 4
theSelectedFaces = (insert poly function so get the face selection array here)
detach_Faces = polyOp.detachFaces theClone theSelectedFaces name:"test_1"

hope this helps!

P.S. i also did a script called "Detach by Material ID" over at scriptspot. you're free to tear it up apart. :D

Polimeno
02-15-2009, 01:27 PM
P.S. i also did a script called "Detach by Material ID" over at scriptspot. you're free to tear it up apart. :D

do you mean this (http://scriptspot.com/3ds-max/detach-by-material-id) script ??
i will take a depth look.


thanks for the explanation too !

CGTalk Moderation
02-15-2009, 01:27 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.