This script do perfect job to crop all mesh object in the scene to the rectangle area
Since last versions of 3dsMax allows to Slice Along both X and Y would it be possible to use only two Slice Modifiers which will be located at top-left and bottom-right of the rectangle shape and be applied to all mesh objects in the scene rather then one-by-one?
(
fn shapeFilt o = (superClassOf o == Shape)
rectObj = pickObject prompt:"Pick Rectangle" filter:shapeFilt
if rectObj != undefined then
(
objs= for obj in objects where superClassOf obj == GeometryClass and obj.isHiddenInVpt == false collect obj
for obj in objs do
(
try(
select obj
addmodifier obj (SliceModifier Slice_Type:3)
objBBox = nodeGetBoundingBox rectObj Obj.transform
obj.modifiers[1].Slice_Plane.transform = (matrix3 [0,0,-1] [0,1,0] [1,0,0] [objBBox[1].x,0,0])
addmodifier obj (SliceModifier Slice_Type:3)
obj.modifiers[1].Slice_Plane.transform = (matrix3 [0,0,1] [0,1,0] [-1,0,0] [objBBox[2].x,0,0])
addmodifier obj (SliceModifier Slice_Type:3)
obj.modifiers[1].Slice_Plane.transform = (matrix3 [0,0,-1] [-1,0,0] [0,1,0] [0,objBBox[1].y,0])
addmodifier obj (SliceModifier Slice_Type:3)
obj.modifiers[1].Slice_Plane.transform = (matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,objBBox[2].y,0])
gc()
convertToMesh obj
meshOps.removeIsolatedVerts obj
if obj.mesh.verts.count == 0 then delete obj
update obj
)catch()
)
)
)
By harumscarum · 2023-09-02