Notifications
Clear all

[Closed] Split Faces of Edit_Poly by mult-sub ID ?

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

4 Replies
 
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

Anyone ?

please…help.

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.

do you meanthis script ??
i will take a depth look.

thanks for the explanation too !