Skip to content

Instantly share code, notes, and snippets.

@apokellypse
Last active April 8, 2019 05:40
Show Gist options
  • Save apokellypse/0e8c426f311ea55a55d664c309fbcb89 to your computer and use it in GitHub Desktop.
Save apokellypse/0e8c426f311ea55a55d664c309fbcb89 to your computer and use it in GitHub Desktop.
Iterative Polycut Along Height of Mesh
// iterative_polycut.mel (using .m only to get gist syntax highlighting)
// author: Kelly Yu
// Get bounding box info on the mesh
float $boundingBox[] = `polyEvaluate -boundingBox bunnyMesh`;
float $ymax = $boundingBox[3];
// We want to cut every 0.125 units
int $numDivisions = $ymax / 0.125;
// Assuming the bottom of the mesh is at 0, this will cut along the mesh's height
for ($i = 0; $i < $numDivisions; $i++) {
float $cutHeight = 0.125 * $i;
// shorthand: polyCut -ws 1 -ch 1 -df 0 -ef 1 -eo .01 .01 .01 -pcy $cutHeight -rx -90 bunnyMesh;
polyCut -worldSpace 1 -constructionHistory 1 -deleteFaces 0 -extractFaces 1 -extractOffset .01 .01 .01 -cutPlaneCenterY $cutHeight -cutPlaneRotateX -90 bunnyMesh;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment