PDA

View Full Version : how to divide an object


boris 333
03-28-2005, 10:11 AM
hello all

i have tried to slice an object using
meshop.slice objects[1] objects[1].faces (point3 1.0 0.0 0.0) 0.0 separate:true

and in did sliceed the object to two elementes now i wont to separate the elemenet in to two different objects, not one object diveded in two element

how can i divide the object to two objects

galagast
03-29-2005, 04:24 AM
someone gave me this script but i forgot who... pretty usefull :thumbsup:


macroScript DetachElements category:"HacksawTOOLS" tooltip:"Split elements into seperate objects" ButtonText:"DetachElements"
(
on isEnabled return
(selection.count >=1)
on execute do
(--start execute loop

--*********************************************************************************************************** FUNCTION DEFINITIONS START
local DetachPolyElements_fn, DetachSplineElements_fn, DetachMeshElements_fn

FN DetachPolyElements_fn SourceOBJ =
(--start function for detaching elements from an editable poly object
MasterObj = SourceOBJ
faceCount = MasterObj.getnumfaces()

FaceTest = ((MasterObj.getnumfaces()) != 0)

for ii in 1 to faceCount while FaceTest do --ends loop when there are no faces left to select
(--start element detach loop
newName = (uniquename (MasterObj.name as string))

MasterObj.EditablePoly.SetSelection #Face #{1}
MasterObj.selectElement()
TargetElement = polyop.getFaceSelection MasterObj
polyop.detachFaces MasterObj TargetElement asNode:true name:newName

NewObj = getnodebyname newName
resetXForm NewObj
convertTo NewObj (Editable_Poly)
ResetTransform NewObj
ResetScale NewObj
ResetPivot NewObj
centerpivot NewObj
FaceTest = ((MasterObj.getnumfaces()) != 0)
)--end element detach loop
delete MasterObj
)--end function for detaching elements from an editable poly object

FN DetachSplineElements_fn SourceOBJ =
(--start function for detaching from editable splines
MasterSpline = SourceOBJ
ns = numsplines MasterSpline

for i in 1 to ns do -- for each element in the spline it re-orders the elements
(
tempMaster = copy MasterSpline
tempMaster.name = (MasterSpline.name + "_Element_" + (i as string))
select tempMaster
setFirstSpline tempMaster i

for ii = ns to 2 by -1 do -- deletes all of the elements except the first one
(
deleteSpline tempMaster ii
)
select MasterSpline
)
delete MasterSpline
)--end function for detaching from editable splines

FN DetachMeshElements_fn SourceOBJ =
(--start function for detaching elements from an editable Mesh object
MasterObj = SourceOBJ
convertTo MasterObj (Editable_Poly)
faceCount = MasterObj.getnumfaces()

FaceTest = ((MasterObj.getnumfaces()) != 0)

for ii in 1 to faceCount while FaceTest do --ends loop when there are no faces left to select
(--start element detach loop
newName = (uniquename (MasterObj.name as string))

MasterObj.EditablePoly.SetSelection #Face #{1}
MasterObj.selectElement()
TargetElement = polyop.getFaceSelection MasterObj
polyop.detachFaces MasterObj TargetElement asNode:true name:newName

NewObj = getnodebyname newName
resetXForm NewObj
convertTo NewObj (Editable_Mesh)
ResetTransform NewObj
ResetScale NewObj
ResetPivot NewObj
centerpivot NewObj
FaceTest = ((MasterObj.getnumfaces()) != 0)
)--end element detach loop
delete MasterObj
)--end function for detaching elements from an editable Mesh object
--*********************************************************************************************************** FUNCTION DEFINITIONS END

max create mode
ObjsSource = getCurrentSelection() --create array of all selected objects
if ObjsSource[1] == undefined then messagebox "Nothing is selected!" -- checks to see something is selected

else for obj in 1 to ObjsSource.count do with redraw off
(--start Object loop
SourceOBJ = ObjsSource[obj]
if (classof SourceOBJ == editable_poly) then (DetachPolyElements_fn SourceOBJ) -- operates only on those objects that are editable polys
else if (classOf SourceOBJ == SplineShape or classOf SourceOBJ == line) then (DetachSplineElements_fn SourceOBJ) -- operates only on those objects that are splines
else if (classOf SourceOBJ == Editable_Mesh) then (DetachMeshElements_fn SourceOBJ) -- operates only on those objects that are editable meshes
)--end Object loop
max views redraw
)--end execute loop
)

Bobo
03-29-2005, 05:06 AM
someone gave me this script but i forgot who... pretty usefull :thumbsup:


"Hacksawtools" sounds like our very own Chris Harvey :)

CGTalk Moderation
03-29-2005, 05:06 AM
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.