Help applying auto smoothing to an object/s.

I’ve been working away at this script for some time now, but I’m still very much in the process of trying to learn MaxScript so trying to build a rather complex script at the same time is just a tad challenging. :P

That being said completing this script will undoubtedly save me weeks or even months depending on the project.

The problem I’m currently having is trying to get the script to Auto Smooth editable poly objects to 45°
Here’s the code.
(I’ve also provided the entire script to give some better context as to what I’m working with)

	-- This will apply the default 45° auto smooth to all selected objects
	fn autosmooth45 tresh: = if selection.count == 0 then (messageBox "Select Some Objects!" title:"Warning" beep:off) else
	(
		local poAS = polyop.autoSmooth
		local moAS = meshop.autosmooth
		for o in selection where isKindOf o GeometryClass and not isKindOf o Targetobject do
		(
			if o.modifiers.count != 0 then (messageBox "Please collapse modifier stack!" title:"Warning" beep:off) else
			(
				case classof o of (
					(Editable_Poly): (poAS o.autoSmoothThreshold ; update o)
					(Editable_Mesh): (moAS o o.faces tresh ; update o)
				)
			)
		)
	)

For those of you who are curious I’m going to be using this script for creating content for a game called Killing Floor 2, more specifically porting maps from the first game (UE2) to the second game (UE3).

Currently I’m having to sort through thousands of objects and it’s taking me months to get the geometry into an acceptable state to be pushed into the KF2 SDK, so having this script will be a massive time saver. XD

AttachmentSize
kf2_auto_task.ms11.34 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Steven_Oconnell's picture

Thanks for the help miauu,

Thanks for the help miauu, unfortunately the script is only working for Editable Meshes and not Editable Polys.

I’m pretty sure the reason is because the local variable that is defined at the top of the function isn’t being used, and due to that Maxscript doesn’t know that the “polyop.autoSmooth” operation is to be performed on the target selection.

miauu's picture

.

The code for Editable Poly that I posted works when the object is selecetd and the subobjectlevl is polygon.

This works with Editable Poly object, when it is not selected, which is faster. Put it in the right place in your script body.

(Editable_Poly): 
(
	o.autoSmoothThreshold = tresh
	polyop.autoSmooth o 
	update o
)
miauu's picture

.

fn autosmooth45 tresh: = if selection.count == 0 then (messageBox "Select Some Objects!" title:"Warning" beep:off) else
	(
		local poAS = polyop.autoSmooth
		local moAS = meshop.autosmooth
		for o in selection where isKindOf o GeometryClass and not isKindOf o Targetobject do
		(
			if o.modifiers.count != 0 then (messageBox "Please collapse modifier stack!" title:"Warning" beep:off) else
			(
				case classof o of 
				(
					(Editable_Poly): 
					(
						o.autoSmoothThreshold = tresh
						o.EditablePoly.autosmooth ()
						update o
					)
					(Editable_Mesh): (moAS o o.faces tresh ; update o)
				)
			)
		)
	)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.