Notifications
Clear all

[Closed] separate two elementes to objects

hello all

i have used
meshop.slice objects[1] objects[1].faces (point3 1.0 0.0 0.0) 0.0 separate:true

to slice an object. now the object is in did sliced and separated to two elementes in the same object. i wont it to be separated to two object i can do it with the user interface that how i know i can do it.
but how can i do it with maxscript ?

3 Replies

here is a script with borrowed bits from swami & ofer zelichover. unfortunately it’s not a one line command, there’s some “massaging” you have to do, but the script works great.

(remove the .txt extension)

Hi,

There is a feature in Orionflame which explodes each elements as a seperate object. Although it only works for EPolys, it should give you the idea. You can get it @ flamefx.com

Light

 The methods meshop.detachFaces and meshop.getElementsUsingFace are the solution.
 Assuming that your sliced object contains only two elements, you could simply say (IN ONE LINE!)
(copy theMesh).mesh = meshop.detachFaces theMesh (meshop.getElementsUsingFace theMesh 1) delete:true asMesh:true
     

where theMesh is you EditableMesh object. The meshop.getElementsUsingFace method takes face with index 1 and returns a bitarray of all faces which are connected to face 1 as element. In other words it returns the first element found in the mesh! Then this bitarray is passed as argument to the meshop.detachFaces method which detaches the faces as a triMesh value and deletes the faces from the original object. Then this TriMesh is assigned to the .mesh property of a copy of the original object, thus replacing the remianing half of the faces in the mesh with the detached half.
Since we are using a copy of the original object, all node-level properties like transformations (incl. animation), material etc. are preserved, and the name is incremented automatically, too…

This is the closest to a single-line command you can come to when detaching to elements. Of course, if there are more elements in the object, you could repeat until there are no faces left in the original, then delete the original.

 Cheers,
 Bobo

(Shameless plug: to learn more one-liner tricks, buy my DVD from CG Academy! ;))