Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Maxscript : Poly_SliceAxis
/*
Poly_SliceAxis
2017/5/12
Align the slice plane local or world xyz axis.
this script works only Editable_Poly or Edit_Poly Modifire.
this script works only when slice plane active.
*/
function change_Slice_Local theMod axis = (
local plane_normal = Point3 0 0 0
local plane_center = Point3 0 0 0
local plane_size = 1.0
if (classof theMod) == Editable_Poly then(
theMod.getSlicePlane &plane_normal &plane_center &plane_size
theMod.setSlicePlane axis plane_center plane_size
)else(
theMod.getSlicePlane &plane_normal &plane_center
theMod.setSlicePlane axis plane_center
)
)
function change_Slice_World theMod axis = (
local plane_normal = Point3 0 0 0
local plane_center = Point3 0 0 0
local plane_size = 1.0
if (classof theMod) == Editable_Poly then(
theMod.getSlicePlane &plane_normal &plane_center &plane_size
)else(
theMod.getSlicePlane &plane_normal &plane_center
)
local nodeTM = $.transform
plane_normal = [0,0,0] * nodeTM
plane_normal += axis
plane_normal = plane_normal * inverse nodeTM
plane_normal = (normalize plane_normal)
if (classof theMod) == Editable_Poly then(
theMod.setSlicePlane plane_normal plane_center plane_size
)else(
theMod.setSlicePlane plane_normal plane_center
)
)
function checkPoly state axis= (
if selection.count == 1 do(
local theMod = modPanel.getCurrentObject()
if (classof theMod) == Editable_Poly then(
if (polyop.inSlicePlaneMode theMod) do(
if state == 1 then(
change_Slice_Local theMod axis
)else if state == 2 then(
change_Slice_World theMod axis
)
)
)
else if (classof theMod) == Edit_Poly then(
if (Edit_Poly.InSlicePlaneMode theMod)do(
if state == 1 then(
change_Slice_Local theMod axis
)else if state == 2 then(
change_Slice_World theMod axis
)
)
)
)
)
try (destroyDialog Roll_SlicePlaneAxis) catch()
rollout Roll_SlicePlaneAxis "SlicePlane Axis"(
-- radiobuttons coordinate_rdo labels:#("Local","World","WorkingPivot")
radiobuttons coordinate_rdo labels:#("Local","World")
group "Axis"(
button x_axis_btn "x" across:3
button y_axis_btn "y"
button z_axis_btn "z"
)
on x_axis_btn pressed do(
checkPoly coordinate_rdo.state [1,0,0]
)
on y_axis_btn pressed do(
checkPoly coordinate_rdo.state [0,1,0]
)
on z_axis_btn pressed do(
checkPoly coordinate_rdo.state [0,0,1]
)
)
createDialog Roll_SlicePlaneAxis 150 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment