PDA

View Full Version : Script Request: Turbosmooth toggle


hsanden
09-27-2009, 03:10 PM
Hi. I come from a modo background, where you can toggle on and off subdivision surfaces by pressing the Tab key. Is there a script for Max that currently does this? Or could anybody make one? It would seriously enhance my workflow.

Basically what I want is:
Being able to toggle on and off smooth by pressing a key while an object is selected. When I first select an object and I fire the command, I want it to smooth out, and when I fire it again, I want to deactivate the smooth.

Thanks!

soulburn3d
09-27-2009, 06:12 PM
That's a little more difficult in max, due to the way max handles subdivs.

In many pieces of software, subdivision is more of an object property. And so it makes sense to be able to turn it on and off.

In max, subdivision is handled in the mesh, it's also handled in the turbosmooth modifier, it's also handled in the meshsmooth modifier. So as well as there being many ways to subdivide, it also can be handled multiple times in the same object.

Like say you have a mesh, you can apply a single turbosmooth, then apply an editpoly modifier and move some vertex around and delete a few faces, then you can apply a second turbosmooth modifier. So in this case, say you want to turn the turbosmooth on and off. Which turbosmooth? If you turn off both turbosmooths, that won't give you what you want since the first turbosmooth is more of a modeling tool, whereas the second turbosmooth is only being used for subdividing. So ideally you'd want to turn off one, and not the other, but it's tough for a script to make those kind of decisions.

Anyways, all that said, I do have a script that does something similar to what you want, it doesn't turn it on or off, but it does let you smooth more or less, the script is called modifySubdivIters

http://www.neilblevins.com/soulburnscripts/soulburnscripts.htm

It can be binded to a hotkey, so you may find it useful. But do realize, as my little explanation above shows, it may not do what you want always.

- Neil

Karnageddon
09-28-2009, 02:57 AM
I wrote this in my spare time as practice and hopefully this will work for what you are looking for.

Cut and paste this into a new Maxscript Editor window and save it wherever you want for convenience.
Run the script from the Maxscript menu then go into Customize>customize UI>Keyboard>Category:ModoFix and select the Turbosmooth Toggle there and apply a keybind to it.
Unfortunately I could not set it to TAB as max does not allow use of that key so you may have to change it to something else or hopefully someone else can point out how.


macroScript TurboSmooth_Toggle category:"Modo Fix"
--Check for selection
(
if selection.count==0 then
(
messagebox "Please select an object."
)
if selection.count>=1 then
(

--Check if TS is applied; if not, apply TS
if (ClassOf $.modifiers[1]) != turbosmooth then
(
addmodifier $ (turbosmooth())
$.turbosmooth.iterations = 1
messagebox ("TurboSmooth added to " + ($.name) as string) title: "NO SUBDIVISION DETECTED!"
)

--Toggle TS state
if $.modifiers[#TurboSmooth].enabled!= true then
$.modifiers[#TurboSmooth].enabled=true
else if $.modifiers[#TurboSmooth].enabled!=false then
$.modifiers[#TurboSmooth].enabled=false
)
)

Notes: Script automatically adds TS subdivision to selected object if missing, Script does not work on multiple selected objects yet.

zortech
09-28-2009, 11:55 AM
haha "Modo Fix".

Someone over at 3dTotal once posted the solution for the mesh.turbosmooth.

I use a script similar to Karnageddon's, as I find it usefull to quickly smooth multiple objects at once. Which however brings a few more problems like excluding all instances and checking for existing smooth modifiers, object types...

hsanden
09-28-2009, 06:55 PM
Thanks a lot, both of you! Works like a charm

Neil: I've been browsing through the rest of the soulburn scripts, and they are awesome. Thanks a lot for them!

labbejason
09-29-2009, 12:09 AM
Don't know if this is too late, but here's something I whipped up that'll increase/decrease turbosmooths from selected objects:

iterationDir = #up -- Change to #up or #down
for o in selection do
(
turboMods = for m in o.modifiers where (classOf m) == turboSmooth collect m -- Collect any TB modifiers on the object
if turboMods.count == 0 do addModifier o (turboSmooth()) -- If none were found, add one to the stack
for m in o.modifiers where (classOf m) == turboSmooth do -- Set iterations of TB
(
case iterationDir of
(
#up: m.iterations += 1
#down: m.iterations -= 1
)
if m.iterations < 0 do m.iterations = 0
)
)

soulburn3d
09-29-2009, 06:08 PM
Neil: I've been browsing through the rest of the soulburn scripts, and they are awesome. Thanks a lot for them!

Thanks, glad you're finding them useful.

- Neil

Mahlon
02-25-2010, 04:34 PM
I wrote this in my spare time as practice and hopefully this will work for what you are looking for.

Cut and paste this into a new Maxscript Editor window and save it wherever you want for convenience.
Run the script from the Maxscript menu then go into Customize>customize UI>Keyboard>Category:ModoFix and select the Turbosmooth Toggle there and apply a keybind to it.
Unfortunately I could not set it to TAB as max does not allow use of that key so you may have to change it to something else or hopefully someone else can point out how.


macroScript TurboSmooth_Toggle category:"Modo Fix"
--Check for selection
(
if selection.count==0 then
(
messagebox "Please select an object."
)
if selection.count>=1 then
(

--Check if TS is applied; if not, apply TS
if (ClassOf $.modifiers[1]) != turbosmooth then
(
addmodifier $ (turbosmooth())
$.turbosmooth.iterations = 1
messagebox ("TurboSmooth added to " + ($.name) as string) title: "NO SUBDIVISION DETECTED!"
)

--Toggle TS state
if $.modifiers[#TurboSmooth].enabled!= true then
$.modifiers[#TurboSmooth].enabled=true
else if $.modifiers[#TurboSmooth].enabled!=false then
$.modifiers[#TurboSmooth].enabled=false
)
)

Notes: Script automatically adds TS subdivision to selected object if missing, Script does not work on multiple selected objects yet.

Thanks so much for that. I've been looking for this function for max 2010 for some time. I couldn't get Michael Comet's to work in 2010.


Mahlon

Arahnoid
05-28-2010, 05:11 PM
Nice script

brazz
03-02-2011, 02:37 PM
Hey Karnageddon, thanks a lot for that script. Having been modelling in maya for a while I was missing this in max, works great. thanks.

CGTalk Moderation
03-02-2011, 02:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.