Skip to content

Instantly share code, notes, and snippets.

@Hoikohroh
Created May 12, 2017 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hoikohroh/2366f85f1465af34eb463e6f106d949c to your computer and use it in GitHub Desktop.
Save Hoikohroh/2366f85f1465af34eb463e6f106d949c to your computer and use it in GitHub Desktop.
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