-- Align to Slice by VerticalHorizontal View.ms -- By Nikolay Litvinov (gniklit@gmail.com) -- Created On: 2016-03-03 -- Modified: 2016-03-03 -- tested using Max 2016 -- 6706 messageBox "Category \"Niklit Scripts\"\nv1.1 If selected vertex sum not 1 then Slice by mouse" macroScript Slice_byVertical_View Category:"Niklit Scripts" Tooltip:"Slice by Vertical View" ( if selection.count>0 do ( max modify mode s1=selection[1] pivot0=s1.pivot ResetPivot s1 vert=getVertSelection s1.mesh as array gco= modPanel.getCurrentObject() planeCenter=if vert.count==1 then ((getPointPos s1 vert[1])-s1.transform.pos) else ((intersectRay s1 (mapScreentoWorldRay mouse.pos)).pos-s1.transform.pos) planeNormal=(inverse (getViewTM())).row1 try gco.setSlicePlane planeNormal planeCenter 20 catch gco.setSlicePlane planeNormal planeCenter fn SlicePlan_fn= try (UIAccessor.PressButton (for i in windows.getChildrenHWND #max where i[5]=="Slice Plane" do exit with i[1])) catch UIAccessor.PressButton (for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where i[5]=="Slice Plane" do exit with i[1]) SlicePlan_fn() try (UIAccessor.PressButton (for i in windows.getChildrenHWND #max where i[5]=="Slice" and i[4]=="CustButton" do exit with i[1])) catch UIAccessor.PressButton (for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where i[5]=="Slice" do exit with i[1]) SlicePlan_fn() if vert.count==1 do try s1.selectedVerts =#{vert[1]} catch (setVertSelection s1 gco #{} keep:off; setVertSelection s1 gco #{vert[1]} keep:on) s1.pivot=pivot0 ) ) macroScript Slice_byHorizontal_View Category:"Niklit Scripts" Tooltip:"Slice by Horizontal View" ( if selection.count>0 do ( max modify mode s1=selection[1] pivot0=s1.pivot ResetPivot s1 vert=getVertSelection s1.mesh as array gco= modPanel.getCurrentObject() planeCenter=if vert.count==1 then ((getPointPos s1 vert[1])-s1.transform.pos) else ((intersectRay s1 (mapScreentoWorldRay mouse.pos)).pos-s1.transform.pos) planeNormal=(inverse (getViewTM())).row2 try gco.setSlicePlane planeNormal planeCenter 20 catch gco.setSlicePlane planeNormal planeCenter fn SlicePlan_fn= try (UIAccessor.PressButton (for i in windows.getChildrenHWND #max where i[5]=="Slice Plane" do exit with i[1])) catch UIAccessor.PressButton (for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where i[5]=="Slice Plane" do exit with i[1]) SlicePlan_fn() try (UIAccessor.PressButton (for i in windows.getChildrenHWND #max where i[5]=="Slice" and i[4]=="CustButton" do exit with i[1])) catch UIAccessor.PressButton (for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where i[5]=="Slice" do exit with i[1]) SlicePlan_fn() if vert.count==1 do try s1.selectedVerts =#{vert[1]} catch (setVertSelection s1 gco #{} keep:off; setVertSelection s1 gco #{vert[1]} keep:on) s1.pivot=pivot0 ) )