/* tmpSelect_macro ConstraintsEdge_Switcher VertexTicks_Switcher ViewCube_Switcher USnap UseSoftSelection_Switcher turnTSSB TransformGizmo_Switcher Turnedge_Switcher SpinEdge_Switcher ShowVertexColors_Switcher seeThrough_Xray_Switcher UnitsSetup showFrozenInGray_Switcher SelfIllumination_Switcher SelectionRegionRectangularPaint_Switcher CoordSys_Switcher AmbientColorBW AmbientOmni MoveSelect_Switcher FrostNova Backfacecull_Switcher constrainType_Switcher ignoreBackfacing_EP_EtP CurrentLayer CreMod_switcher Length_macro ShapeConnectCopyCheckbox_Switcher Shapeselect autoBackup_switcher CommandPanelWindowPos2monitor_Switcher positiontemp ShapeRenderMesh ScaleNegative_Switcher */ messagebox "Location Category:\"Switchers\"" macroScript tmpSelect_macro Category:"Switchers" Tooltip:"tmpSelect Switcher" icon:#("Containers",15) ( global curSet fn notisEmptycurSet_fn = curSet!=undefined --on isEnabled return on ischecked return notisEmptycurSet_fn() on Execute do case notisEmptycurSet_fn() of ( true: try ((for i in selection do append curSet i); select curSet; unhide curSet; curSet=undefined) catch curSet=undefined false: if selection.count>0 do curSet=selection as array ) ) macroScript ConstraintsEdge_Switcher Category:"Switchers" Tooltip:"Constraints Edge" icon: #("Snap_Points",5) silentErrors: true ( try ( gco=modPanel.getCurrentObject() case gco.constrainType of ( 0: gco.constrainType = 1 1: gco.constrainType = 0 default: gco.constrainType = 0 ) )catch() ) macroScript VertexTicks_Switcher Category:"Switchers" Tooltip:"Vertex Ticks Switcher" icon:#("SubObjectIcons",1) ( global VTicks on isEnabled return selection.count>0 and superclassof selection[1]==GeometryClass on ischecked return (for o in selection do if o.VertexTicks then VTicks=on else VTicks=off; VTicks) on Execute do if VTicks then (for obj in selection do obj.VertexTicks = off) else (for obj in selection do obj.VertexTicks = on) max views redraw ) macroScript ViewCube_Switcher Category:"Switchers" Tooltip:"ViewCube Switcher" icon:#("ViewportNavigationControls",11) ( on ischecked return ViewCubeOps.Visibility on Execute do ( ViewCubeOps.Visibility=if ViewCubeOps.Visibility == false then true else false ViewCubeOps.GoHome() Completeredraw() ) ) macroScript USnap Category:"Switchers" Tooltip:"U-Snap" ( gco = modPanel.getCurrentObject() if classof gco==Unwrap_UVW then case of ( default: actionMan.executeAction 2077580866 "40132" (keyboard.altPressed and not keyboard.shiftPressed and not keyboard.controlPressed): gco.unwrap.snap () ) else max snap toggle ) macroScript UseSoftSelection_Switcher Category:"Switchers" Tooltip:"UseSoftSelection" icon:#("UVWUnwrapSoftSelection",1) ( global useSoftS global gco rollout useSoftSelRollout "Falloff" width:90 height:21 ( spinner spn_useSoftSel "" range: [0,999999,0.2] type: #float align:#left scale:0.01 width:88 height:16 pos:[1,2] on spn_useSoftSel changed arg do (gco.falloff = arg) ) on isEnabled return selection.count>0 and getCommandPanelTaskMode() == #modify and subobjectlevel!=0 on ischecked return ( gco=modpanel.getcurrentobject() if (classof gco==Edit_Poly or classof gco==Editable_Poly) and gco.useSoftSel == on then useSoftS=on else useSoftS=off; return useSoftS) on Execute do if useSoftS then (gco.useSoftSel = off; try DestroyDialog useSoftSelRollout catch()) else (gco.useSoftSel = on; CreateDialog useSoftSelRollout; gco.falloff=0.2) max views redraw ) macroScript turnTSSB Category:"Switchers" Tooltip:"Turn time slider" ( global turnVTS Case turnVTS of ( undefined: turnVTS=(trackbar.visible = off timeslider.setvisible off 2) 2: turnVTS=(statusPanel.visible = off 3) 3: turnVTS=(trackbar.visible=on timeslider.setvisible on statusPanel.visible = on undefined) ) ) macroScript TransformGizmo_Switcher Category:"Switchers" Tooltip:"Transform Gizmo Switcher" icon: #("UVWUnwrapTools2",13) silentErrors: true ( global NitrViewSet on isEnabled return selection.count>0 on ischecked return tmGizmos.useGizmo==on on execute do (tmGizmos.useGizmo = if tmGizmos.useGizmo==on then off else on if keyboard.escPressed do actionMan.executeAction 0 "418" -- Tools: Transform Gizmo Size Up if keyboard.shiftPressed do actionMan.executeAction 0 "419" -- Tools: Transform Gizmo Size Down ) ) macroScript Turnedge_Switcher Category:"Switchers" Tooltip:"Turn Edge" icon:#("bip_curve",1) silentErrors: true ( fn FiltObj =( gco=modPanel.getCurrentObject() f= if (classof gco==Editable_Poly or classof gco==Edit_Poly) and gco.getCommandMode()==#turnedge then true else false ) on ischecked return FiltObj() on Execute do if FiltObj() then try (subobjectlevel=2; gco.ToggleCommandMode #turnedge; $.alledges =false) catch() else try (subobjectlevel=2; gco.ToggleCommandMode #turnedge; $.alledges =true) catch() ) macroScript SpinEdge_Switcher category:"Switchers" toolTip:"Spin Edge" icon:#("",1) ( gco=modPanel.getCurrentObject() if selection.count==1 do case subobjectlevel of ( 2: macros.run "PolyTools" "SpinEdge" 4: for f in (gco.getSelection #Face) do selection[1].TurnDiagonal f 1 ) ) macroScript ShowVertexColors_Switcher Category:"Switchers" Tooltip:"Show Vertex Colors" icon:#("PolyTools",15) ( global VertClr on isEnabled return selection.count>0 on ischecked return (for o in selection do if o.ShowVertexColors then VertClr=on else VertClr=off; VertClr) on Execute do if VertClr then (for obj in selection do obj.ShowVertexColors = off) else (for obj in selection do obj.ShowVertexColors = on) max views redraw ) macroScript seeThrough_Xray_Switcher Category:"Switchers" Tooltip:"See-Through (Xray)" icon:#("SnapsControls",12) ( global XrayState on ischecked return (for i in selection do if i.Xray then XrayState=on else XrayState=off; XrayState) on Execute do if XrayState then (for obj in selection do obj.Xray = off) else (for obj in selection do obj.Xray = on) max views redraw ) macroScript UnitsSetup Category:"Switchers" Tooltip:"UnitsSetup mm/m" buttontext: "mm"--icon:#("SnapsControls",12) ( global MetricState on ischecked return (if (units.MetricType==#millimeters and units.SystemType==#millimeters and units.DisplayType==#metric) then MetricState=on else MetricState=off; MetricState) on Execute do case MetricState of ( false: (units.MetricType=#millimeters; units.SystemType=#millimeters; units.DisplayType=#metric) true: (units.MetricType=#meters; units.SystemType=#meters; units.DisplayType=#Generic) ) ) macroScript showFrozenInGray_Switcher Category:"Switchers" Tooltip:"Show Frozen InGray" icon:#("SnapsControls",4) ( global FrState on ischecked return (for o in selection do if o.ShowFrozenInGray then FrState=on else FrState=off; FrState) on Execute do if keyboard.escPressed then $.material=undefined else ( if FrState then (for obj in selection do obj.ShowFrozenInGray = off) else (for obj in selection do obj.ShowFrozenInGray = on) ) max views redraw ) macroScript SelfIllumination_Switcher Category:"Switchers" Tooltip:"SelfIllumination Switcher" icon:#("Systems",2) ( fn changeMtl mtl = (if isKindOf mtl Standard do (mtl.showInViewport = on mtl.selfIllumAmount = if mtl.selfIllumAmount != 100 then 100 else 0)) on isEnabled return selection.count>0 on ischecked return (try($.material.selfIllumAmount == 100)catch()) on execute do ( if selection.count != 0 do ( for obj in selection where obj.material != undefined do ( case (classof obj.material) of ( multimaterial: for m in obj.material.materialList do changeMtl m standard: changeMtl obj.material ) ) ) ) ) macroScript SelectionRegionRectangularPaint_Switcher category:"Switchers" tooltip:"Selection Region Rectangular/Paint switcher" ( gco=modpanel.getcurrentObject() global turnSz, RollSizeSelBrush, RollSizeSelBrush_UVW, HWND_uvE fn EditUVWs_isOpen_fn = ( EditUVWs_isOpen = false ChildWindows = UIAccessor.GetChildWindows (DialogMonitorOPS.GetWindowHandle()) --for i in ChildWindows do format "%\n" (UIAccessor.GetWindowText i) for i in ChildWindows where (UIAccessor.GetWindowText i)=="Edit UVWs" do exit with EditUVWs_isOpen = true EditUVWs_isOpen ) rollout RollSizeSelBrush "SizeSelBr" width:130 height:20 ( slider sld1 "" range:[1,100,30] pos:[1,-10] width:137 height:25 type:#integer on sld1 changed val do maxOps.paintSelBrushSize=val) rollout RollSizeSelBrush_UVW "SizeSelBr" width:130 height:20 ( slider sld1 "" range:[1,100,30] pos:[1,-10] width:137 height:25 type:#integer on sld1 changed val do (if gco.getPaintSelectMode()==off then (gco.setPaintSelectSize val; gco.setPaintSelectMode on) else (gco.setPaintSelectMode off; gco.setPaintSelectSize val; gco.setPaintSelectMode on))) if classof gco == Unwrap_UVW then if gco.getPaintSelectMode() == false and EditUVWs_isOpen_fn()==true then ( gco.setPaintSelectMode on gco.setPaintSelectSize 30 try DestroyDialog RollSizeSelBrush_UVW catch(); CreateDialog RollSizeSelBrush_UVW pos: [900,230] parent: HWND_uvE ) else (gco.setPaintSelectMode off; try (DestroyDialog RollSizeSelBrush_UVW) catch()) else Case turnSz of ( undefined: turnSz=( actionMan.executeAction 0 "59236"; try DestroyDialog RollSizeSelBrush catch(); CreateDialog RollSizeSelBrush pos: [900,230];1) 1: turnSz=( actionMan.executeAction 0 "59232"; try (DestroyDialog RollSizeSelBrush) catch(); undefined) ) ) macroScript CoordSys_Switcher category:"Switchers" toolTip:"Coorsys Switcher" ( if keyboard.escPressed then setRefCoordSys #local else ( case getRefCoordSys() of ( #screen: (setRefCoordSys #hybrid) #hybrid: (setRefCoordSys #screen) default: (setRefCoordSys #hybrid) ) ) ) macroScript AmbientColorBW Category:"Switchers" Tooltip:"Ambient Color BW" icon:#("PhotometricLights",4) --silentErrors: true ( global state_AmbC --on isEnabled return state_AmbC==on on ischecked return state_AmbC==on on Execute do( if state_AmbC==off or state_AmbC==undefined then (ambientColor = color 255 255 255; state_AmbC=on) else (ambientColor = color 0 0 0; state_AmbC=off) ) ) macroScript AmbientOmni Category:"Switchers" Tooltip:"AOmni" icon:#("Lights",3) silentErrors: true ( global state_omni --on isEnabled return state_omni==on on ischecked return (for o in objects where classof o==Omnilight and o.name=="AmbientOmni" collect o).count>0 on Execute do ( if state_omni==off or state_omni==undefined then (Omnilight ambientOnly: on name:"AmbientOmni"; state_omni=on) else (delete (for o in objects where classof o==Omnilight collect o); state_omni=off) ) ) macroScript MoveSelect_Switcher Category:"Switchers" Tooltip:"Move-Select Switcher" ( If toolmode.commandmode == #select then (max move) else (max select) ) macroScript FrostNova Category:"Switchers" Tooltip:"FrostNova" icon:#("UVWUnwrapView",17) ( if selection.count>0 then ( if keyboard.altPressed then (max freeze inv) else if not keyboard.escPressed then ($.showFrozenInGray=off; max freeze selection) else (max freeze selection) ) else try( if keyboard.escPressed then (max unfreeze by hit) else if keyboard.shiftPressed then (max unfreeze by name) else max unfreeze all )catch() ) macroScript Backfacecull_Switcher Category:"Switchers" Tooltip:"Backfacecull Switcher" icon:#("UVWUnwrapSelection",12) ( fn isBackfaceCull = ( local node, f = false for node in selection do if node.backfacecull then ( f=true exit ) return f )--fn isBackfaceCull on isEnabled return selection.count > 0 on ischecked return isBackfaceCull() on Execute do if isBackfaceCull() then (for obj in selection do obj.backfacecull = off) else (for obj in selection do obj.backfacecull = on) ForceCompleteRedraw() ) macroScript constrainType_Switcher Category:"Switchers" Tooltip:"ConstrainType Switcher" icon:#("Snap_Points",3) ( global gco fn constrainType_fn = try (gco=modPanel.getCurrentObject(); gco.constrainType==1) catch() on isEnabled return selection.count > 0 on ischecked return constrainType_fn() on Execute do case constrainType_fn() of ( true: try gco.constrainType=0 catch() false: try gco.constrainType=1 catch() default:() ) ) macroScript ignoreBackfacing_EP_EtP category:"Switchers" toolTip:"ignoreBackfacing_EP_EtP" icon:#("UVWUnwrapSelection",25) ( gco=modpanel.getcurrentobject() try (gco.ignoreBackfacing = if gco.ignoreBackfacing==off then on else off) catch (if classof gco==Unwrap_UVW then if gco.getIgnoreBackFaceCull()==off then gco.setIgnoreBackFaceCull on else gco.setIgnoreBackFaceCull off) ) macroScript CurrentLayer Category:"Switchers" Tooltip:"CurrentLayer" icon:#("AnimLayerToolbar",12) silentErrors: true ( fn CurL =(f = if selection.count!=0 and (selection[1].layer.current==true) then true else false) on isEnabled return selection.count>0 on ischecked return CurL() on Execute do if CurL() then try (selection[1].layer.current=off) catch() else try (selection[1].layer.current=on) catch() ) macroScript CreMod_switcher category:"Switchers" tooltip:"Create-Modify switcher" ( if getCommandPanelTaskMode() != #create then (max create mode) Else (max modify mode) max select ResumeEditing() selection[1].layer.current = true ) macroScript Length_macro category:"Switchers" tooltip:"Length" silentErrors: true ( if keyboard.escPressed then macros.run "Objects Helpers" "Tape" else if classof $ == Tape then ( rayFromTape=($ as ray) IntersectObjs=(intersectRayScene rayFromTape) print (distance ((for i in IntersectObjs where not i[1].isHidden collect i)[1][2]).pos $.pos) ) else ( global hwndCallback, splLG_fn, lg unregisterRedrawViewsCallback splLG_fn try (deleteChangeHandler hwndCallback) catch() if IsShapeObject $ then ( fn splLG_fn=( lgSeg=getSegLengths $ 1 lg= (if classof selection[1] == Circle then selection[1].radius*2*pi else lgSeg[lgSeg.count] as string) --PushPrompt (lg+" "+(units.MetricType as string)) Print (lg+(if units.MetricType==#millimeters do "mm")) setclipboardText lg ) splLG_fn() callbacks.removeScripts id:#remClbk callbacks.addScript #selectionSetChanged "unregisterRedrawViewsCallback splLG_fn" id:#remClbk registerRedrawViewsCallback splLG_fn ) else if (subobjectlevel==0 or subobjectlevel==undefined) then ( setCommandPanelTaskMode #utility (UIAccessor.PressButton (for i in windows.getChildrenHWND #max where i[5]=="Measure" do exit with i[1])) ) else ( gco=modPanel.getCurrentObject() if classof gco==Editable_Poly or classof gco==Edit_Poly then case subObjectLevel of ( 1: ( fn lg_fn1 ar=(posVrt=try(for i=1 to ar.count collect #((gco.GetVertex ar[i][1] node: selection[i]),(gco.GetVertex ar[i][2] node: selection[i])))[1] catch (for i in ar collect polyop.getVert $ i) setclipboardText (lg=(distance posVrt[1] posVrt[2]) as string); --PushPrompt (lg+" "+(units.MetricType as string)) Print (lg+(if units.MetricType==#millimeters do "mm")) ) vrt=try (for i in selection collect (gco.getselection #vertex node: i) as array)[1] catch (polyop.getVertSelection $ as array) if vrt.count==2 do ( lg_fn1 vrt hwndCallback = try (when geometry $ changes do lg_fn1 vrt) catch deleteChangeHandler hwndCallback ) ) 2: ( fn lg_fn2 ar= ( posVrt=for i in ar collect (v=((polyop.getVertsUsingEdge $ i) as array); distance (polyop.getVert $ v[1]) (polyop.getVert $ v[2])) lg=0; local p=posVrt.count while p>=1 do (lg+=posVrt[p]; p-=1) --PushPrompt (lg as string+" "+(units.MetricType as string)) Print (lg as string + (if units.MetricType==#millimeters do "mm")) ) edg=polyop.getEdgeSelection $ if edg.count>0 do ( lg_fn2 edg hwndCallback= try (when geometry $ changes do lg_fn2 edg) catch deleteChangeHandler hwndCallback ) ) ) ) ) ) macroScript ShapeConnectCopyCheckbox_Switcher Category:"Switchers" Tooltip:"Shape Connect Copy Checkbox Switcher" icon:#("SubObjectIcons",38) ( /* global handleConnect global BM_CLICK=245 global BM_GETCHECK=240 fn FILT_ConnectCopyShape_fn=( if selection.count>0 and \ getCommandPanelTaskMode()==#modify and \ subobjectlevel!=0 and \ subobjectlevel!=1 and \ superclassof $==shape \ then on else off ) --DesktopChild=(windows.getChildrenHWND (windows.getDesktopHWND())) --clearlistener(); for i in DesktopChild do format "%\n" i fn Handle_ConnectCopyShape_fn= try ( DesktopChild=(windows.getChildrenHWND (windows.getDesktopHWND())) handleConnect=for i=1 to DesktopChild.count where DesktopChild[i][5]=="Connect Copy" do exit with DesktopChild[(i+1)][1]) catch ( if (child_HWND=for i in windows.getChildrenHWND #max where i[5]=="Geometry" do exit with i[2]; child_HWND==Ok) do child_HWND=for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where i[5]=="Geometry" do exit with i[2] archild_HWND=windows.getChildrenHWND child_HWND for i=1 to archild_HWND.count where archild_HWND[i][5]=="Connect Copy" do handleConnect=archild_HWND[i+1] ) on isEnabled return FILT_ConnectCopyShape_fn() on ischecked return ( f=off if FILT_ConnectCopyShape_fn() do ( Handle_ConnectCopyShape_fn() currentState = windows.sendMessage handleConnect BM_GETCHECK 0 0 case currentState of ( 0: f=off 1: f=on ) ) f==on ) on execute do ( Handle_ConnectCopyShape_fn() currentState = windows.sendMessage handleConnect BM_GETCHECK 0 0 case currentState of ( 0: UIAccessor.SendMessage handleConnect BM_CLICK 1 0 -- SetCheck 1: UIAccessor.SendMessage handleConnect BM_CLICK 1 0 -- UnsetCheck ) ) */) macroScript Shapeselect Category:"Switchers" Tooltip:"Shapeselect" icon:#("HairAndFur",17) ( select (for i in objects where superClassOf i == shape and (not i.isHidden) collect i) ) macroScript autoBackup_switcher Category:"Switchers" Tooltip:"AutoBackup switcher" icon:#("AnimLayerToolbar",3) ( fn autoBackup_State =(f = if autoBackup.enabled==true then true else false) on ischecked return autoBackup_State() on Execute do if autoBackup_State() then autoBackup.enabled=off else autoBackup.enabled=on ) /* macroScript CommandPanelWindowPos2monitor_Switcher category:"Switchers" toolTip:"CommandPanel Window Pos 2 monitor Switcher" icon:#("SubObjectIcons",26) ( global CP_hwnd, CP_Winpos --on isEnabled return (for i in windows.getChildrenHWND #max where i[5]=="Command Panel" do exit with i[1])==ok on ischecked return ( CP_hwnd=(for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where i[5]=="Command Panel" do exit with i[1]) CP_Winpos=windows.getWindowPos CP_hwnd CP_Winpos.x>1500 ) --for i in (windows.getChildrenHWND (windows.getDesktopHWND())) do format "%\n" i --windows.setWindowPos on Execute do if CP_Winpos.x>1500 then windows.setWindowPos CP_hwnd 1416 146 184 674 on else windows.setWindowPos CP_hwnd 1919 95 376 904 on ) */ macroScript positiontemp category:"Switchers" toolTip:"position temp" icon:#("UVWUnwrapTools",36) ( global pos_tmp0 on ischecked return pos_tmp0!=undefined on execute do if pos_tmp0 == undefined then if selection.count>0 do pos_tmp0=for i in selection collect #(i, i.pos) else ( pos_tmp1 = for i=1 to pos_tmp0.count where IsValidNode pos_tmp0[i][1]==true collect pos_tmp0[i] select (for i=1 to pos_tmp1.count collect pos_tmp1[i][1]) for i=1 to selection.count do selection[i].pos = pos_tmp1[i][2] pos_tmp0=undefined ) ) macroScript ShapeRenderMesh category:"Switchers" toolTip:"Shape RenderMesh" icon:#("PowerBoolean",8) --silentErrors: true ( on isEnabled return if superclassof selection[1] == shape then true else false on ischecked return if superclassof selection[1] == shape and selection[1].render_displayRenderMesh then true else false on execute do ( if selection.count>0 do shapes0=for i in selection where superclassof i == shape collect i try case selection[1].render_displayRenderMesh of ( false: for i in shapes0 do ( i.render_renderable=on i.render_displayRenderMesh=on ) true: for i in shapes0 do ( i.render_renderable=off i.render_displayRenderMesh=off ) ) catch() ) ) macroScript ScaleNegative_Switcher Category:"Switchers" Tooltip:"ScaleNegative_Switcher" icon:#("UVWUnwrapTools",33) ( fn ScaleNegativeFixer_fn fco =( ResetXForm fco AddModifier fco (Normalmodifier ()) fco.modifiers[#Normal].flip = on collapseStack fco ) global ScaleState on ischecked return try (for o in selection do if o.scale==[-1,-1,-1] then (ScaleState=on; PushPrompt (o.name as string + "Fixed scale [-1,-1,-1]")) else ScaleState=off; ScaleState) catch ScaleState=off on Execute do if ScaleState do for o in selection where o.scale==[-1,-1,-1] do ScaleNegativeFixer_fn o )