--Slices a geometry object on x,y and z axis in equal intervals using the Slice modifier. --written by Christoph Bülter 06.09.2011 try(destroyDialog ro_sliceObject)catch() rollout ro_sliceObject "Slice Object" width:116 height:197 ( local theObj = undefined local offset = 0 fn geo_filt obj = superclassof obj == geometryClass pickButton pkb_obj "Pick object to slice" pos:[3,4] width:110 height:30 filter:geo_filt spinner spnL "Length: " pos:[26,56] width:78 height:16 range:[0,9999,4] type:#integer scale:1 spinner spnW "Width: " pos:[26,77] width:78 height:16 range:[0,9999,4] type:#integer scale:1 spinner spnH "Height: " pos:[26,98] width:78 height:16 range:[0,9999,0] type:#integer scale:1 groupBox grp1 "Slices along..." pos:[3,38] width:110 height:83 checkbox chk_split "Split Mesh" pos:[8,126] width:84 height:18 checked:true checkbox chk_collapse "Collapse stack" pos:[8,144] width:112 height:18 checked:true button btn_slice "Slice!" pos:[3,170] width:110 height:24 fn createBB i= ( b bb = nodeGetBoundingBox i i.transform size = (bb[2]-bb[1]) in coordsys i ( b = box width:size[1] length:size[2] height:size[3] wirecolor:(random black white) CenterPivot b b.transform = i.transform b.pivot = i.pivot b.pos = i.center )--end coord b --return reference )--end fn on pkb_obj picked obj do ( pkb_obj.caption = "Picked: " + obj.name theObj = obj )--end on on btn_slice pressed do ( if theObj != undefined AND isValidNode theObj do ( max create mode bb = createBB theObj local objLength = bb.length local objWidth = bb.width local objHeight = bb.height delete bb --slice along width: offset = 0 --reset for i=1 to spnW.value do ( offset += objWidth / spnW.value as Float theMod = sliceModifier() if chk_split.checked then theMod.slice_Type = 1 else theMod.slice_Type = 0 theMod.slicePlane.rotation = (quat -0.5 -0.5 -0.5 -0.5) theMod.slicePlane.position = in coordsys theObj ( [theObj.pos.x - objWidth/2.0 + offset, theObj.pos.y, theObj.pos.z] ) addModifier theObj theMod )--end for --slice along length: offset = 0 --reset for i=1 to spnL.value do ( offset += objLength / spnL.value as Float theMod = sliceModifier() if chk_split.checked then theMod.slice_Type = 1 else theMod.slice_Type = 0 theMod.slicePlane.rotation = (quat 0.707107 0 0 0.707107) theMod.slicePlane.position = in coordsys theObj ( [theObj.pos.x, theObj.pos.y - objLength/2.0 + offset, theObj.pos.z] ) addModifier theObj theMod )--end for --slice along height: offset = 0 --reset for i=1 to spnH.value do ( offset += objHeight / spnH.value as Float theMod = sliceModifier() if chk_split.checked then theMod.slice_Type = 1 else theMod.slice_Type = 0 theMod.slicePlane.rotation = (quat 0 0 0 1) theMod.slicePlane.position = in coordsys theObj ( [theObj.pos.x, theObj.pos.y, theObj.pos.z + offset] ) addModifier theObj theMod )--end for if chk_collapse.checked do ( collapseStack theObj )--end if )--end if )--end on ) createDialog ro_sliceObject