Notifications
Clear all

[Closed] detachToElement does not work?

Hi! I have an editable poly mesh that is split into many different parts, but I need to attach all parts together before I can create morph targets for it. The problem is that I have to repeat the attach/detach process every time I need to create a new morph target for the model, and I also have to rename each detached part to specific naming requirements.

I am trying to automate the attach/detach/rename process using MaxScript by recording the detaching/renaming part, but for some reason the script fails to detach the currently selected polys when detachToElement is executed. Here is a simple example to illustrate the issue, where a simple editable poly cylinder called “p01” is being split into chunks “p02” and “p03”:

===================================
select $p01
subobjectLevel = 5
modPanel.setCurrentObject $p01.baseObject
$.EditablePoly.SetSelection #Face #{20…37}
$.EditablePoly.detachToElement #Face keepOriginal:off
$Object01.name = “p02”
$.EditablePoly.SetSelection #Face #{20…38}
$.EditablePoly.detachToElement #Face keepOriginal:off
$Object01.name = “p03”

The script fails to “detachToElement”, where MaxScript returns “true” but does not split the geometry. It apparently does nothing, so the next line fails. What do I have to do to make this work?

Please help (I am desperate!),
–=Ken

2 Replies

Hi,
try this: select your object (Editable_poly) and run this script:

(
  	obj = selection[1]
  	if classof obj == editable_poly do
  	(
  		while obj.numfaces!=0 do
  		(
  			el=polyop.getelementsusingface obj 1
  			newObjName=uniquename (obj.name+"_00")
  			polyop.detachFaces obj el delete:true asNode:true name:newObjName
  		)
  	)
  )

Thanks for your help! I realize the listener records “detachToElement” when the detach button is pressed, but in reality, the proper command should be “detachFaces”.

What I am doing here is to create full body morph targets for a rigged character, where the mesh must be split into separate body parts that are assigned to respective bones that control them. The problem is that morph targets can only be created after the body has all parts reattached back together into a single piece.

Once the morph target is created, I must split the geometry back into multiple body parts and rename them to the respective body parts. I must repeat this process for each and every morph target creation, so MaxScript seemed like a good idea to automate the splitting and renaming part.

The problem here is that each body part has a unique name that must be preserved, so automation with random sequential names cannot be used. Body parts like “head”, “neck”, “rForeArm” and so on have to be set to the right body part after detached. Since every character has a different geometry, I assume the process cannot be automated, because the script would not know which detached geometry is which in the process of restoring their body part name. Right now I am writing scripts manually for each different character model, and I suppose this is the only way this can be done.

Is there a way to create morph targets for a character without having to attach all of the body parts back together? As far as I know, 3DSMAX is not capable of editing sub-component level elements (vertexes, edges, faces) on a model with detached geometry. This can be done in Maya using “poly groups”, where morph targets are preserved even if the base model has been modified.

Since both MAX and Maya are now under the common Autodesk umbrella, I wonder if 3DSMAX can do something like that?