View Full Version : Script to clear smoothing groups & assign to 1?
08-05-2007, 07:29 PM
Hi, I have another maxScript question :)
I would like to be able to set a quadmenu shortcut that would both clear my smoothing groups, and assign them to the same smoothing group (let's say smoothing group 1). The basic effect I'm looking for is to be able to select an object and smooth all the normals for that object with one click.
Right now, the clear smoothing groups works, which gives the result of all the normals being hard. But, when I try to follow that up with setting the smoothing groups to 1, my script errors when I try to run it. I used the MaxScript Listener Window to record what I thought were the commands for what I wanted to do (by performing the actions manually)
Any idea why this might not work?
Thanks for any help
08-05-2007, 11:34 PM
I wrote a script similar to this...
on isEnabled return
selection.count == 1 and classOf selection.baseobject == Editable_Poly
On execute do
ShowEndRes = ShowEndResult
if ShowEndResult == true then (ShowEndResult = false)
v = subObjectLevel
subobjectLevel = 4
sel = polyop.getFaceSelection $
max select all
$.autoSmoothThreshold = 180
polyop.setFaceSelection $ sel
subobjectLevel = v
ShowEndResult = ShowEndRes
08-06-2007, 03:10 PM
Don't pay too much mind to the listener window. It usually spits out garbage code. Use the maxscript reference if possible.
The method you want to use is polyop.setFaceSmoothGroup which takes an object, a bitarray of face numbers, and an integer representing the SG you want to apply.
Here's an example that you could copy and paste into a new maxscript window, and the select all and drag to a toolbar to make it a macro script. The try/catch is there to simply cut down on error checking, since this is a simple script, and does not warrent error checking for number of objects selected, and whether or not it's an editable poly. So the try/catch just silently ignores any errors. Sounds like a usefull tool for when you go to project your normals.
fn ClearSGs =
local numFaces = polyop.getNumfaces $
local faces = (for i in 1 to numFaces collect i) as bitarray
polyOp.setFaceSmoothGroup $ faces 1
08-06-2007, 03:10 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.