[Closed] Shading selected objects in a colour
That’s very cool! Some things I noticed off the bat though is that it conflicts while trying to create new objects. Also if you modify the mesh, like changing the radius of a sphere, the ‘selection’ object won’t update. I also just got it to crash while reselecting the object over and over.
One thing I messed around with was making the selection object an instance, so when you change the mesh, it’ll move along with it. Again, cool stuff!
Thank you Jason! Great input, though a reference would fit better, as when instancing the base mesh, it will also get the push modifier applied to it.
I have changed the key word within the code.
You’re right about the object creation, as well as the re-selecting thing…also pressing undo doesn’t work quite well. Hm I’m gonna add an On Off button xD
If it were possible to bind that to a keyboard shortcut, this script of yours will DEFINITELY be going in my startup folder!
Cheers!
Edit: fixed reselecting bug by freezing the reference node
No problem. This is some kind of a workaround, but I have no idea how I can quickly do it solid. (The On/Off button solution)
Well its kinda bitchy to make one single toggle macro, because with a max version older than 2009 there's no function to easily check if a callback is currently active. Like the [b]"Searching for Callbacks.." [/b]thread shows.
Change the category's name if you like. It's just that my name is "Max" :D
[b] macroScript [color=White]u3SelectionOn [/color][/b]category:"max'sScripts" tooltip:"Activate u3Selection"
(
callbacks.removeScripts id:#U3Selection --// unregister the callback
[b]local [/b]aPrevSelection = #() --// array containing previous selection
[b]local [/b]objShadeMesh = #() --// array containing cloned objects
[b]local [/b]mSelMaterial = standard()
mSelMaterial.opacity = 50
mSelMaterial.diffuse = (color 150 10 200)
mSelMaterial.selfIllumColor = (color 150 10 200)
mSelMaterial.useSelfIllumColor = true
[b]global [/b]fnU3Selection = [b]function [/b]fnU3Selection =
(
[b]if [/b]objShadeMesh != undefined [b]and [/b]objShadeMesh.count > 0 [b]do[/b]
(
[b]for [/b]o[b] in [/b]objShadeMesh [b]do try [/b](delete [b]o[/b])[b] catch[/b]()
objShadeMesh = #()
)
aPrevSelection = [b]for [/b]o [b]in [/b]selection [b]where [/b]superClassOf o == GeometryClass [b]collect [/b]o
[b]for [/b]i = 1 [b]to [/b]aPrevSelection.count [b]do [/b]
(
objShadeMesh[i] = reference aPrevSelection[i]
addModifier objShadeMesh[i] (push Push_Value:1.5) --// increase the push value if necessary
objShadeMesh[i].material = mSelMaterial
objShadeMesh[i].parent = aPrevSelection[i]
objShadeMesh[i].showFrozenInGray = off
freeze objShadeMesh[i]
)
)
callbacks.addScript #selectionSetChanged "fnU3Selection()" id:#U3Selection
)
[b]macroScript [color=White]u3SelectionOff [/b][/color]category:"max'sScripts" tooltip:"Deactivate u3Selection"
(
callbacks.removeScripts id:#U3Selection --// unregister the callback
)
No need to put this into your startup folder. Just as before open and run it once and the functions "Activate / Deactivate..." will be added to the appropriate category within the customize menu.
[color=PaleGreen][/color]