supremepizza
01-06-2008, 11:28 AM
I have a script that chops up any poly object but I don't explode the elements until later because I want to do a soft selection based on the center vertex.
Here's the snippet that does the work.
--dice it up
on btnDice pressed do
(
--check if an object is selected if not messagebox warning
if selection.count < 1 then
(
messagebox "Please select an object." Beep: on
)
--check if more than one object is selected if true messagebox warning
if selection.count > 1 then
(
messagebox "Only one object can be split at once." Beep: on
)
--check if object is a poly if not converts to poly
if selection.count ==1 and classof $ != Editable_Poly then
(
--$.pos = [0,0,0]
convertToPoly($)
)
--checks if object count is 1 and poly then runs if true
if selection.count == 1 and classof $ == Editable_Poly thenundooff--when undo is on undoing operation crashes Max
(
setwaitcursor()--waitcursor = hourglass cursor while running script
--$.pos = [0,0,0]-- position object to world center
MoveMax = $.max-$.pivot--defines dimension of the object
MoveMin = $.min-$.pivot--defines dimension of the object
VarChops = spnChopLVL.value --create variable for # of chops
--Dice It up
for i = 1 to VarChops do
(
polyop.setFaceSelection $ #all--selects all faces of the selected object
polyops.startsliceplane($)--starts the slice plane
--Move and rotate slice plane randomly
Wm_SliceRotate = [(random -1.0 1.0),(random -1.0 1.0),(random -1.0 1.0)]--sets a random value for rotatioin of slice plane
Wm_SliceMove = [(random MoveMin.x MoveMax.x),(random MoveMin.y MoveMax.y),(random MoveMin.z MoveMax.z)]--sets a random value for movement of slice plane
$.split = true--turns on split option for slice plane
$.slice Wm_SliceRotate Wm_SliceMove --slices defined by the random values declared above
polyOp.capHolesByEdge $.baseobject #all--caps holes created by slice/split
polyOp.CollapseDeadStructs--removes any dead structures that could have possibly been created
)
It continues on from there to select a random face and extract the elements rename them, put them in an array, UVW wrap, unwrap then hide them etc.
---detach elements by selecting a face and create new objects from elements
Here's the snippet that does the work.
--dice it up
on btnDice pressed do
(
--check if an object is selected if not messagebox warning
if selection.count < 1 then
(
messagebox "Please select an object." Beep: on
)
--check if more than one object is selected if true messagebox warning
if selection.count > 1 then
(
messagebox "Only one object can be split at once." Beep: on
)
--check if object is a poly if not converts to poly
if selection.count ==1 and classof $ != Editable_Poly then
(
--$.pos = [0,0,0]
convertToPoly($)
)
--checks if object count is 1 and poly then runs if true
if selection.count == 1 and classof $ == Editable_Poly thenundooff--when undo is on undoing operation crashes Max
(
setwaitcursor()--waitcursor = hourglass cursor while running script
--$.pos = [0,0,0]-- position object to world center
MoveMax = $.max-$.pivot--defines dimension of the object
MoveMin = $.min-$.pivot--defines dimension of the object
VarChops = spnChopLVL.value --create variable for # of chops
--Dice It up
for i = 1 to VarChops do
(
polyop.setFaceSelection $ #all--selects all faces of the selected object
polyops.startsliceplane($)--starts the slice plane
--Move and rotate slice plane randomly
Wm_SliceRotate = [(random -1.0 1.0),(random -1.0 1.0),(random -1.0 1.0)]--sets a random value for rotatioin of slice plane
Wm_SliceMove = [(random MoveMin.x MoveMax.x),(random MoveMin.y MoveMax.y),(random MoveMin.z MoveMax.z)]--sets a random value for movement of slice plane
$.split = true--turns on split option for slice plane
$.slice Wm_SliceRotate Wm_SliceMove --slices defined by the random values declared above
polyOp.capHolesByEdge $.baseobject #all--caps holes created by slice/split
polyOp.CollapseDeadStructs--removes any dead structures that could have possibly been created
)
It continues on from there to select a random face and extract the elements rename them, put them in an array, UVW wrap, unwrap then hide them etc.
---detach elements by selecting a face and create new objects from elements
