Scripting Level of Detail utility in 3dsmax

You can’t do it.

UDK supports importing LODs from a single FBX using the FBX LOD groups, this is awesome, except that you can only make this in 3dsmax by using the Level of Detail utility. The LOD utility is not scriptable, and is not cool for workflow. It looks like most of the function of LOD sets hinges on the visiblity:LOD_Controller controller so I figured I could just build the LODs on export through script. Some of my favorite mxs reference:

Constructor

The LOD_Controller controller is not creatable by MAXScript. It can only be created using the Level of Detail utility.

Properties

There are no additional properties for LOD_Controller.

It looks to me like the best option to get around the LOD utility would be to edit an ascii FBX post export, and build the FBX lod groups that way.

Has anyone had the need to script the LOD utility? Or otherwise made FBX LOD groups without it?

How about something like that? :): It’s UIAccessor hackery, but it works. :slight_smile:

To make it useful for your purpose, just pass it the necessary array of meshes.


(
	struct LodManager
	(
		fn createLodExample =
		(
			theLodSetExampleArray = #()
			for i = 1 to 3 do
				append theLodSetExampleArray (teapot segments:i wirecolor: [255 - (85 * i),85 * i,0])
			
			group theLodSetExampleArray
			
			theLodSetExampleArray
		),
		
		fn PressCreateNewSetButton =
		(
			max utility mode
			UtilityPanel.OpenUtility Level_of_Detail
			panel = (windows.getChildHWND #max "Utilities")
			CreateNewSetButton = (windows.getChildHWND (UIAccessor.GetParentWindow panel[3]) "Create New Set")
			UIAccessor.PressButton CreateNewSetButton[1]
		)		
		
	)
	
	local lodMaker = LodManager()
	clearSelection()
	
	local myMeshArray = (lodMaker.createLodExample())
	select myMeshArray
	lodMaker.PressCreateNewSetButton()

)

Spencer I think your original workaround is the better one: “It looks to me like the best option to get around the LOD utility would be to edit an ascii FBX post export, and build the FBX lod groups that way.”

Note that there is an FBX SDK you may be able to use, rather than trying to parse the ascii FBX files, which are a real beast.

I understand it very closely…

Thanks for the feedback guys.

I went with j83 suggestion for the speed of getting something in, and I’m not too familiar with FBX or its sdk yet. It worked well for now, although I did have to change it a bit to work on my machine.


setCommandPanelTaskMode #utility
UtilityPanel.OpenUtility Level_of_Detail
panel = (windows.getChildHWND #max "Level of Detail")
CreateNewSetButton = (windows.getChildHWND panel[3] "Create New Set")	

I didn’t think much about it at the time but now I’m seeing that my changes don’t work on some other peoples machines. I’m assuming there are differences in the orders of how the windows are ordered and seeded. For the same reason I needed to change your initial script for it to work for me.

Have you run into this sort of thing before?

Hello,

That is interesting. Did the user get an error, or did something silently just not work? I have used this type of thing on other scripts without any problems.

If this problem persists for you, perhaps you can iterate the the values in the stored arrays, searching for the correct ones.

Btw, we use Max 2010 currently, so I haven’t tried it in other versions of Max.

Jonathan, woaah, this is awesome in a very evil way:

CreateNewSetButton = (windows.getChildHWND (UIAccessor.GetParentWindow panel[3]) "Create New Set")
UIAccessor.PressButton CreateNewSetButton[1]

SamiV.

Where there’s a will there’s a way. :wink:

panel: Global:panel : undefined