Script to clear smoothing groups & assign to 1?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  08 August 2007
Question Script to clear smoothing groups & assign to 1?

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)

$.EditablePoly.setSmoothingGroups 0

$.EditablePoly.setSmoothingGroups 1

Any idea why this might not work?

Thanks for any help

I think Unicorns are Kickass!

Last edited by foreverendering : 08 August 2007 at 07:32 PM.
  08 August 2007
I wrote a script similar to this...

macroScript SmoothingGroup1
 category: "BCTools"
 	on isEnabled return
 		selection.count == 1 and classOf selection[1].baseobject == Editable_Poly
 	On execute do
 		ShowEndRes = ShowEndResult
 		if ShowEndResult == true then (ShowEndResult = false)
 		v = subObjectLevel
 		subobjectLevel = 4
 		sel = polyop.getFaceSelection $
 		print sel
 		max select all
 		$.autoSmoothThreshold = 180
 		$.EditablePoly.autosmooth ()
 		polyop.setFaceSelection $ sel
 		subobjectLevel = v
 		ShowEndResult = ShowEndRes
  08 August 2007
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


Now with more ninjas!
  08 August 2007
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 04:41 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.