Trouble with rollout creator

Hi, I wonder if someone can help show me what I'm doing wrong here. The script is a little hacky tool to create a list of checkboxes that each correspond to a material ID in a mesh. The idea is that clicking the checkboxes on and off hides and unhides the polys with those ID's.

I don't need anything fancy, so right now, I'm stipulating that the mesh has an edit poly modifier, and a delete mesh modifier above it. The script selects polys in the epoly modifier which then is the subobject selection for the delete mesh. I tried hiding them, but they still render, and I don't want that.

Ugly, I know, but I just want to get it working, then get fancier if I have time :)

Anyway, here's the script. The error I'm getting is that the checkbox handler isn't recognizing the function "chkboxHandler" as defined. Scoping issue? To me, the fn seems like it's in the right place. I'm pretty stumped.

Thanks for looking :)

(
	local node = $ 
	local mat = node.material;
	local matNum = mat.numsubs
	local nodeName = node.name
	local visArray = #()
	local setPolys	
 
	fn setPolys =
	(	
		select node
		ePoly = node.modifiers[#Edit_Poly]
		modPanel.setCurrentObject ePoly
		subobjectLevel = 4
		ePoly.SetSelection #Face #{} 
		ePoly.selectByMaterialClear = off
		for m = 1 to  mat.numsubs do (
 
			if( visArray[m] ) do (
				ePoly.selectByMaterialID = m
				ePoly.ButtonOp #SelectByMaterial
			)
		)
		modPanel.setCurrentObject node.modifiers[#DeleteMesh]
		deselect node;
	)
 
	fn chkboxHandler index state = 
	(
		visArray[index] = state;
		format"checkbox:% %\n" index visArray[index] 
		setPolys();
	)				
 
	rci = rolloutCreator "matVis" nodeName
	rci.begin();
 
	for m = 1 to  matNum do (
		visArray[m] = false;
		local boxName = ("chkbox" + m as string) as name
		rci.addControl #checkbox boxName ("ID_" + m as string)
		local str = "chkboxHandler " + (m as string) + " val" -- doing it here to be able to debug the string that is being used
		rci.addHandler boxName #changed paramStr:"val" codeStr:str
	)
	rci.end()
 
	matFloater = newRolloutFloater "set Material ID Vis" 100 (35 + matNum * 21);
	(
		addRollout rci.def matFloater
	)
)

Comments

Comment viewing options

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

Hi Pshenk, rolloutCreator()

Hi Pshenk,

rolloutCreator() is a scripted function located in your Max "stdplugs\stdscripts\baseLib\rolloutCreator.ms".
In the .ms file you can find more about how to use it.
Finaly rolloutCreator() build string and use execute() function.
So, if you don't like it's struct, you can build your own string.

If you decide to use rolloutCreator():
1. If you use Local variables then you must add them by ".addLocal".
2. For the functions you need ".addText", that require:
2.1. Function to be converted to string replacing quotation marks with @
2.2. In ".addText" filter must be allowed.

my_fn = messageBox "Hello!" -- example fn
str = "my_fn = messageBox @Hello!@" -- converted
rci.addText str filter:true -- filter must be on

I hope this helps

my recent MAXScripts RSS (archive here)

Comment viewing options

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