Notifications
Clear all

[Closed] Update button state in other rollout/dialogue

Hi!

I’m currently writing a little script which is also able to change the snap settings.
I’ve got one (check-)button for each: toggle general snapping, toggle vertex snapping, toggle grid snapping.
Unfortunately, it works well when only using these buttons.

But as soon as you change something (either per shortcut, main toolbar or per quadmenu entries which I also created) the whole thing gets out of sync with my rollout/dialogue because it doesn’t update the checkbuttons in it.

I’ve searched the docs, looking for a possible callback or such but didn’t find anything except maybe a time-based callback (which would be a quite a overhead I guess…)
Does anybody have a clue how to get this solved in an appropriate way?

Here’s the script, but:

  1. currently I’ve changed the snap buttons back to buttons and not checkbuttons
  2. it’s not cleaned up yet – so look at your own risk

In case anybody examines the code: am I doing anything very very aweful in case of performance? =)
I am grateful for any suggestions, as this is my first maxscript.

----------------------------------------------------------------------------------------------------
 -- uMax
 -- Autor: Christian Herzog, email: Giggsy@gmx.at
 -- Description: a little script which makes life a bit easier when working with the UnrealEngine3. 
 -- Tested with: 
 --	
[li] 3D Studio Max 9 SP2[/li] --	
[li] 3D Studio Max 2008[/li] ----------------------------------------------------------------------------------------------------
 
 ----------------------------------------------------------------------------------------------------
 -- The macro scripts:
 ----------------------------------------------------------------------------------------------------
 macroScript uMax_SetGridTo_4
 category:"uMax" 
 tooltip:"Set grid to 4 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 4.0 )
 )
 
 macroScript uMax_SetGridTo_8
 category:"uMax" 
 tooltip:"Set grid to 8 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 8.0 )
 )
 
 macroScript uMax_SetGridTo_16
 category:"uMax" 
 tooltip:"Set grid to 16 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 16.0 )
 )
 
 macroScript uMax_SetGridTo_32
 category:"uMax" 
 tooltip:"Set grid to 32 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 32.0 )
 )
 
 macroScript uMax_SetGridTo_64
 category:"uMax" 
 tooltip:"Set grid to 64 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 64.0 )
 )
 
 macroScript uMax_SetGridTo_128
 category:"uMax" 
 tooltip:"Set grid to 128 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 128.0 )
 )
 
 macroScript uMax_SetGridTo_256
 category:"uMax" 
 tooltip:"Set grid to 256 UU" 
 (
 	units.SystemScale = 2.0
 	units.SystemType = #Centimeters
 	units.CustomUnit = #Centimeters
 	units.CustomValue = 2.0
 	units.CustomName = "UU"
 	units.DisplayType = #custom
 	gridPrefs.spacing = ( 256.0 )
 )
 
 macroScript uMax_ToggleSnapping
 category:"uMax" 
 tooltip:"Toggle snapping" 
 (
 	if snapMode.active then ( snapMode.active = false )
 	else ( snapMode.active = true )
 )
 
 macroScript uMax_ToggleGridSnapping
 category:"uMax" 
 tooltip:"Toggle grid snapping" 
 (
 	--Save which snapping options where selected:
 	if( snapMode.getOSnapItemActive 5 1 ) then ( bVertSnap =  true )
 	else ( bVertSnap = false )
 
 	if( snapMode.getOSnapItemActive 2 1) then ( bGridSnap =  false )
 	else ( bGridSnap = true )
 
 
 	--Set all setOSnapItemsActive to false...
 	for i = 1 to snapmode.numOSnaps do
 	( 
 		for j = 1 to ( snapmode.getOSnapNumItems i ) do
 			( snapmode.setOSnapItemActive i j false )
 	)
 
 	--And now set the selected ones back to true again:
 	if bVertSnap then ( snapMode.setOSnapItemActive 5 1 true )
 	if bGridSnap then ( snapMode.setOSnapItemActive 2 1 true )
 )
 
 macroScript uMax_ToggleVertexSnapping
 category:"uMax" 
 tooltip:"Toggle vertex snapping" 
 (
 	--Save which snapping options where selected:
 	if( snapMode.getOSnapItemActive 5 1 ) then ( bVertSnap =  false )
 	else ( bVertSnap = true )
 
 	if( snapMode.getOSnapItemActive 2 1) then ( bGridSnap =  true )
 	else ( bGridSnap = false )
 
 
 	--Set all setOSnapItemsActive to false...
 	for i = 1 to snapmode.numOSnaps do
 	( 
 		for j = 1 to ( snapmode.getOSnapNumItems i ) do
 			( snapmode.setOSnapItemActive i j false )
 	)
 
 	--And now set the selected ones back to true again:
 	if bVertSnap then ( snapMode.setOSnapItemActive 5 1 true )
 	if bGridSnap then ( snapMode.setOSnapItemActive 2 1 true )
 )
 
 macroScript uMax_snapUVWToGrid
 category:"uMax" 
 tooltip:"Snap UVW gizmo to grid" 
 (
 	if( $selection.count > 0 ) then
 	(
 		if( $.modifiers[#UVW_Mapping] != undefined ) then
 		(
 			--print "applied"
 			uvwmap = $.modifiers[#UVW_Mapping]
 			pos = uvwmap.gizmo.position
 			print uvwmap.gizmo.position
 			
 			--First, convert pos coords to int:
 			pos.x = pos.x as Integer
 			pos.y = pos.y as Integer
 			pos.z = pos.z as Integer
 
 			--Second, move to grid:
 			gridRes = gridPrefs.spacing
 			
 			modResultX = mod pos.x gridRes
 			modResultY = mod pos.y gridRes
 			modResultZ = mod pos.z gridRes
 			
 			--Snap to nearest grid point:
 			if( pos.x > 0 ) then
 			(
 				if( modResultX < (gridRes/2) ) then ( pos.x -= modResultX	)
 				else( pos.x += ( gridRes - modResultX ) )
 			)
 			else 
 			(
 				if( modResultX > (-gridRes/2) ) then ( pos.x -= modResultX )
 				else( pos.x += ( -gridRes - modResultX ) )
 			)
 
 			if( pos.y > 0 ) then
 			(
 				if( modResultY < (gridRes/2) ) then ( pos.y -= modResultY	)
 				else( pos.y += ( gridRes - modResultY ) )
 			)
 			else 
 			(
 				if( modResultY > (-gridRes/2) ) then ( pos.y -= modResultY )
 				else( pos.y += ( -gridRes - modResultY ) )
 			)
 
 			if( pos.z > 0 ) then
 			(
 				if( modResultZ < (gridRes/2) ) then ( pos.z -= modResultZ	)
 				else( pos.z += ( gridRes - modResultZ ) )
 			)
 			else 
 			(
 				if( modResultZ > (-gridRes/2) ) then ( pos.z -= modResultZ )
 				else( pos.z += ( -gridRes - modResultZ ) )
 			)
 			uvwmap.gizmo.position = pos
 		)
 	)
 )
 
 macroScript uMax_snapVertsToGrid
 category:"uMax" 
 tooltip:"Snap verts to grid" 
 (
 	vArray = polyop.getvertselection $ as array
 	
 	for i in vArray do
 	(
 		vert = polyop.getvert $ i
 		
 		--First, convert pos coords to int:
 		vert.x = vert.x as Integer
 		vert.y = vert.y as Integer
 		vert.z = vert.z as Integer
 
 		--Second, move to grid:
 		gridRes = gridPrefs.spacing
 		
 		modResultX = mod vert.x gridRes
 		modResultY = mod vert.y gridRes
 		modResultZ = mod vert.z gridRes
 		
 		--Snap to nearest grid point:
 		if( vert.x > 0 ) then
 		(
 			if( modResultX < (gridRes/2) ) then ( vert.x -= modResultX	)
 			else( vert.x += ( gridRes - modResultX ) )
 		)
 		else 
 		(
 			if( modResultX > (-gridRes/2) ) then ( vert.x -= modResultX )
 			else( vert.x += ( -gridRes - modResultX ) )
 		)
 
 		if( vert.y > 0 ) then
 		(
 			if( modResultY < (gridRes/2) ) then ( vert.y -= modResultY	)
 			else( vert.y += ( gridRes - modResultY ) )
 		)
 		else 
 		(
 			if( modResultY > (-gridRes/2) ) then ( vert.y -= modResultY )
 			else( vert.y += ( -gridRes - modResultY ) )
 		)
 
 		if( vert.z > 0 ) then
 		(
 			if( modResultZ < (gridRes/2) ) then ( vert.z -= modResultZ	)
 			else( vert.z += ( gridRes - modResultZ ) )
 		)
 		else 
 		(
 			if( modResultZ > (-gridRes/2) ) then ( vert.z -= modResultZ )
 			else( vert.z += ( -gridRes - modResultZ ) )
 		)	
 
 		polyop.setvert $ i vert
 	)
 )
 
 macroScript uMax_snapObjsToGrid
 category:"uMax" 
 tooltip:"Snap objects to grid" 
 (
 	for i in selection do
 	(
 		--First, convert pos coords to int:
 		i.pos.x = i.pos.x as Integer
 		i.pos.y = i.pos.y as Integer
 		i.pos.z = i.pos.z as Integer
 
 		--Second, move to grid:
 		gridRes = gridPrefs.spacing
 		
 		modResultX = mod i.pos.x gridRes
 		modResultY = mod i.pos.y gridRes
 		modResultZ = mod i.pos.z gridRes
 		
 		--Snap to nearest grid point:
 		if( i.pos.x > 0 ) then
 		(
 			if( modResultX < (gridRes/2) ) then ( i.pos.x -= modResultX	)
 			else( i.pos.x += ( gridRes - modResultX ) )
 		)
 		else 
 		(
 			if( modResultX > (-gridRes/2) ) then ( i.pos.x -= modResultX )
 			else( i.pos.x += ( -gridRes - modResultX ) )
 		)
 
 		if( i.pos.y > 0 ) then
 		(
 			if( modResultY < (gridRes/2) ) then ( i.pos.y -= modResultY	)
 			else( i.pos.y += ( gridRes - modResultY ) )
 		)
 		else 
 		(
 			if( modResultY > (-gridRes/2) ) then ( i.pos.y -= modResultY )
 			else( i.pos.y += ( -gridRes - modResultY ) )
 		)
 
 		if( i.pos.z > 0 ) then
 		(
 			if( modResultZ < (gridRes/2) ) then ( i.pos.z -= modResultZ	)
 			else( i.pos.z += ( gridRes - modResultZ ) )
 		)
 		else 
 		(
 			if( modResultZ > (-gridRes/2) ) then ( i.pos.z -= modResultZ )
 			else( i.pos.z += ( -gridRes - modResultZ ) )
 		)
 	)
 )
 
 
 ----------------------------------------------------------------------------------------------------
 -- Main rollout menu:
 ----------------------------------------------------------------------------------------------------
 rollout uMaxTools "uMax 0.95" 
 (
 	--Some global vars:
 	--global SUB_EXPORT_DIR = "export\\"
 	global SUB_EXPORT_DIR = ""
 
 	----------------------------------------------------------------------------------------------------
 	--The GUI stuff:
 	----------------------------------------------------------------------------------------------------
 	group "Collision settings"
 	(
 		button but_ubx "UBX" across:3 toolTip:"Rename selected object(s) to UBX (Unreal box collision)."
 		button but_usp "USP" toolTip:"Rename selected object(s) to USP (Unreal sphere collision)."
 		button but_ucx "UCX" toolTip:"Rename selected object(s) to UCX (Unreal convex collision)."
 		button but_ubx2 "BBX" across:3 toolTip:"Autocreate bounding box mesh of selected objects."
 		button but_usp2 "BSP" toolTip:"Autocreate bounding sphere mesh of selected objects."
 		button but_ucx2 "BCX" toolTip:"Autocreate bounding convex mesh of selected objects - NOT IMPLEMENTED YET." enabled:false
 	)
 
 	group "Export settings"
 	(
 		--checkbutton security_export_mode "SEC MODE" align:#center across:2 tooltip:"Toggle security mode: see documentation for further details." checked:false
 		
 		button sm_export_all "ALL" across:3 toolTip:"Exports all objects to ASE file."
 		button sm_export_sel "SEL" toolTip:"Exports selected objects to ASE file." -- Export selected only.
 		button sm_export_sel_zero "S+0" toolTip:"Exports selected objects to ASE file from 0/0/0." -- Export selected only - centered to 0/0/0.
 	
 		label exp_dir_lab "Export directory:" align:#left across:1
 		edittext target_dir text:maxFilePath  readOnly:true across:1--width:324 height:18 --pos:[319,257]
 		button pick_dir "PICK DIR" align:#center tooltip:"Pick export directory." across:2
 		button update_export_dir "UPDATE" tooltip:"Update export directory to scene file directory."
 	
 		label exp_fileName_lab "File name:" align:#left across:1
 		edittext target_fileName text:(getFilenameFile maxFileName) width:120 across:2
 	
 		button update_scene_name "U" tooltip:"Update scene file name."  pos:[137,208]
 	)
 
 	group "Grid settings"
 	(
 		dropdownlist scale_dd "Change grid to Unreal:" items:#("4", "8", "16", "32", "64", "128", "256")
 		label custom_grid_label "Set custom grid:" align:#left
 		edittext custom_grid_value across:2
 		button custom_grid_button "OK" tooltip:"Apply custom grid." pos:[90,320]
 	)
 
 	group "Snap settings"
 	(
 		--checkbutton snap_but "ON" tooltip:"Toggle general snapping on and off." checked:snapMode.active across:3
 		button snap_but "toggle" tooltip:"Toggle general snapping on and off." checked:snapMode.active across:3
 		button vert_snap_but " V " tooltip:"Toggle vertex snapping." --was checkbutton
 		button grid_snap_but " G " tooltip:"Toggle grid snapping."
 
 		button snapUVWMapGizmo_but "UVW" across:3 toolTip:"Snaps the UVW Mapping gizmo to the grid."
 		button snapVert2Grid_but "VTX" toolTip:"Snaps the selected vert(s) to the grid."
 		button snapObj2Grid_but "OBJ" toolTip:"Snaps the selected object(s) to the grid."
 	)
 
 	group "Other"
 	(
 		button fix_materials_button "CLEAN MAT" across:2 align:#center tooltip:"Cleans all sub-materials of unused ones" 
 		button info_but " README " 
 		--button readMe_but "ReadMe"
 	)
 
 
 	----------------------------------------------------------------------------------------------------
 	--The event handling/logic stuff:
 	----------------------------------------------------------------------------------------------------
 	/*
 	on security_export_mode changed state do 
 	(
 		if state then ( security_export_mode.state = true )
 		else ( security_export_mode.state = false )
 	)
 	*/
 	
 	on fix_materials_button pressed do
 	(
 		Clean_MultiMaterial.fixAll prompt:true
 	)
 	
 	on sm_export_all pressed do
 	(
 		global exportDir
 		global exportFileName
 		global SUB_EXPORT_DIR
 		bExport = true
 
 		makeDir ( exportDir + SUB_EXPORT_DIR ) all:true
 		
 		--If entered name is blank, use the object's name as file name:
 		if( exportFileName == "" ) then
 		(
 			output_name = getSaveFileName caption:"caption" filename:( exportDir + SUB_EXPORT_DIR ) types:"ASE(*.ASE)|"
 			if( output_name == undefined ) then bExport = false
 		)
 		
 		--Else, use the entered file name:
 		else 
 		(
 			output_name = exportDir + SUB_EXPORT_DIR + exportFileName 
 		)			
 
 		if( bExport ) then exportFile output_name selectedOnly:false using:AsciiExp
 	)
 	
 	on sm_export_sel pressed do
 	(
 		global exportDir
 		global exportFileName
 		global SUB_EXPORT_DIR 
 		bExport = true
 
 		if( selection.count > 0 ) then
 		(
 			makeDir ( exportDir + SUB_EXPORT_DIR ) all:true
 			
 			--If entered name is blank, use the object's name as file name:
 			if( exportFileName == "" ) then
 			(
 				if( selection.count == 1 ) then objName = $.name
 				else objName = $[1].name
 
 				/*
 				--If "security mode", then prompt for file name:
 				if( security_export_mode.checked ) then
 				(
 					output_name = getSaveFileName caption:"caption" filename:( exportDir + SUB_EXPORT_DIR + objName + ".ASE" ) types:"ASE(*.ASE)|"
 					if( output_name == undefined ) then bExport = false
 				)
 				
 				--Else, just use object's name as file name:
 				else
 				(
 				*/
 					output_name = exportDir + SUB_EXPORT_DIR + objName
 				--)
 			)
 			
 			--Else, use the entered file name:
 			else 
 			(
 				output_name = exportDir + SUB_EXPORT_DIR + exportFileName 
 			)			
 
 			if( bExport ) then exportFile output_name selectedOnly:true using:AsciiExp
 		)
 		
 		else
 		(
 			--TODO: either export all objects or throw warning to user...
 			--exportFile (exportDir+exportFileName) selectedOnly:false using:AsciiExp
 		)
 	)
 
 	on sm_export_sel_zero pressed do
 	(
 		global exportDir
 		global exportFileName
 		global SUB_EXPORT_DIR
 		bExport = true
 		old_center = selection.center
 
 		--Move selection to center:
 		move selection -selection.center
 	
 		if( selection.count > 0 ) then
 		(
 			makeDir ( exportDir + SUB_EXPORT_DIR ) all:true
 			
 			--If entered name is blank, use the object's name as file name:
 			if( exportFileName == "" ) then
 			(
 				if( selection.count == 1 ) then objName = $.name
 				else objName = $[1].name
 			
 				/*
 				--If "security mode", then prompt for file name:
 				if( security_export_mode.checked ) then
 				(
 					output_name = getSaveFileName caption:"caption" filename:( exportDir + SUB_EXPORT_DIR + objName + ".ASE" ) types:"ASE(*.ASE)|"
 					if( output_name == undefined ) then bExport = false
 				)
 				
 				--Else, just use object's name as file name:
 				else
 				(
 				*/
 					output_name = exportDir + SUB_EXPORT_DIR + objName
 				--)
 			)
 			
 			--Else, use the entered file name:
 			else 
 			(
 				output_name = exportDir + SUB_EXPORT_DIR + exportFileName 
 			)			
 	
 			if( bExport ) then exportFile output_name selectedOnly:true using:AsciiExp
 		)
 		
 		else
 		(
 			--TODO: either export all objects or throw warning to user...
 		)
 		
 		--Move back:
 		move selection old_center
 	)
 	
 		
 	-- Custom save path:
 	global exportDir = maxFilePath   
 	global exportFileName = ( getFilenameFile maxFileName )
 		
 	on pick_dir pressed do
 	(
 		if( p = ( getsavepath initialdir:target_dir.text ) ) != undefined do
 		(
 			target_dir.text = p + "\\"
 			exportDir = target_dir.text
 		)
 	)
 
 	on update_export_dir pressed do
 	(
 		target_dir.text = maxFilePath
 		exportDir = target_dir.text
 	)
 
 	on update_scene_name pressed do
 	(
 		target_fileName.text = ( getFilenameFile maxFileName )
 		exportFileName = target_fileName.text
 	)
 	
 	on target_fileName changed newtext do 
 	(
 		exportFileName = newtext
 	)	
  
 	-- Rename to collision objects:
 	on but_ubx pressed do
 	(
 		for i in selection do i.name = "UBX" --uniquename "UBX"
 	) 
 
 	on but_usp pressed do
 	(
 		for i in selection do i.name = "USP" --uniquename "USP"
 	) 
 
 	on but_ucx pressed do
 	(
 		for i in selection do i.name = "UCX" --uniquename "UCX"
 	) 
 
 	on but_ubx2 pressed do
 	(
 		for obj in selection do 
 		(
 			boxData = obj.max - obj.min
 			newBox = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:boxData.y width:boxData.x height:boxData.z mapcoords:on
 			newBox.name = "UBX"
 			newBox.pos = obj.center
 			newBox.pos.z = newBox.pos.z - ( boxData.z / 2 )
 			newBox.xray = on
 		)
 	)
 
 	on but_usp2 pressed do
 	(
 		for obj in selection do 
 		(
 			sphereData = obj.max - obj.min
 			longest = sphereData.x
 			 if( sphereData.y > longest ) then longest = sphereData.y
 			else if( sphereData.z > longest ) then longest = sphereData.z
 			
 			newSphere = Sphere radius:( longest / 2 ) smooth:on segs:32 chop:0 slice:off sliceFrom:0 sliceTo:0 mapcoords:on recenter:off pos:obj.center 
 			newSphere.name = "USP"
 			newSphere.xray = on
 		)
 	)
 
 	-- Drop down list:
 	on scale_dd selected i do
 	(
 		case (scale_dd.items[i] as Integer) of
 		(
 		4:	macros.run "uMax" "uMax_SetGridTo_4"
 		8:	macros.run "uMax" "uMax_SetGridTo_8"
 		16: macros.run "uMax" "uMax_SetGridTo_16"
 		32: macros.run "uMax" "uMax_SetGridTo_32"
 		64: macros.run "uMax" "uMax_SetGridTo_64"
 		128: macros.run "uMax" "uMax_SetGridTo_128"
 		256: macros.run "uMax" "uMax_SetGridTo_256"
 		)
 
 	)
 	
 	-- Custom grid settings:
 	on custom_grid_button pressed do
 	(
 		if( ( custom_grid_value.text as float ) > 0 ) then
 		(
 			units.SystemScale = 2.0
 			units.SystemType = #Centimeters
 			units.CustomUnit = #Centimeters
 			units.CustomValue = 2.0
 			units.CustomName = "UU"
 			units.DisplayType = #custom
 			gridPrefs.spacing = ( custom_grid_value.text as float )
 		)
 	)
  
 	--on snap_but changed state do 
 	on snap_but pressed do
 	(
 		macros.run "uMax" "uMax_ToggleSnapping"
 	)
 	
 	--on vert_snap_but changed state do 
 	on vert_snap_but pressed do
 	(
 		macros.run "uMax" "uMax_ToggleVertexSnapping"
 	)
 
 	--on grid_snap_but changed state do 
 	on grid_snap_but pressed do 
 	(
 		macros.run "uMax" "uMax_ToggleGridSnapping"
 	)
 	
 	on snapUVWMapGizmo_but pressed do 
 	(
 		macros.run "uMax" "uMax_snapUVWToGrid"
 	)
 
 	on snapVert2Grid_but pressed do 
 	(
 		macros.run "uMax" "uMax_snapVertsToGrid"
 	)
 	
 	on snapObj2Grid_but pressed do 
 	(
 		macros.run "uMax" "uMax_snapObjsToGrid"
 	)
 
 	on info_but pressed do 
 	(
 		rollout about_dialogue "ReadMe/About"
 		(
 			label base_title "uMax" 
 			label base_name "Author: Christian Herzog" across:2 align:#left
 			label base_email "Email: Giggsy@gmx.at" 
 			
 			label base_readme1 "Please see the uMax_readme.pdf for more information!" across:1 align:#left
 			label empty ""
 
 			button close_about_but "   CLOSE   " 
 			on close_about_but pressed do
 			(
 				DestroyDialog about_dialogue
 			)
 		)
 		createDialog about_dialogue 280 110
 	)
 
 	on readMe_but pressed do 
 	(
 		rollout readme_dialogue "ReadMe"
 		(
 			label base_readme1 "Please see the uMax_readme.pdf" 
 			label base_readme2 "for more information!"
 			label empty ""
 
 			button close_readme_but "CLOSE" 
 			on close_readme_but pressed do
 			(
 				DestroyDialog readme_dialogue
 			)
 		)
 		createDialog readme_dialogue 250 85
 	)
 )
 ----------------------------------------------------------------------------------------------------
 -- Main ROLLOUT menu - END.
 ----------------------------------------------------------------------------------------------------
 
 -- Create the final dialog:
 clearListener()
 createDialog uMaxTools 175 480
 
 
 ---------------------------------------------------------------------------------
 --Build the quad menu - ONCE ONLY! (used genClassID returnValue:false )
 ---------------------------------------------------------------------------------
 if menuMan.registerMenuContext 0xbbb7291 then
 (
 	-- Get the default viewport right-click quad menu
 	quadMenu = menuMan.getViewportRightClickMenu #nonePressed
 	
 	-- Get the lower-left menu from the quad
 	menu = quadMenu.getMenu 4
 
 	--Add a separator:
 	--menu.addItem  (menuMan.createSeparatorItem()) -1
 	
 	toggleSnapItem = menuMan.createActionItem "uMax_ToggleSnapping" "uMax"
 	toggleSnapItem.setTitle "Toggle snapping"
 	toggleSnapItem.setUseCustomTitle true
 	menu.addItem toggleSnapItem 0
 
 	toggleGridSnapItem = menuMan.createActionItem "uMax_ToggleGridSnapping" "uMax"
 	toggleGridSnapItem.setTitle "Toggle grid snapping"
 	toggleGridSnapItem.setUseCustomTitle true
 	menu.addItem toggleGridSnapItem 0
 
 	toggleVertexSnapItem = menuMan.createActionItem "uMax_ToggleVertexSnapping" "uMax"
 	toggleVertexSnapItem.setTitle "Toggle vertex snapping"
 	toggleVertexSnapItem.setUseCustomTitle true
 	menu.addItem toggleVertexSnapItem 0
 
 	snapUVWToGridItem = menuMan.createActionItem "uMax_snapUVWToGrid" "uMax"
 	snapUVWToGridItem .setTitle "Snap UVW gizmo to grid"
 	snapUVWToGridItem .setUseCustomTitle true
 	menu.addItem snapUVWToGridItem 0
 	
 	snapVertsToGridItem = menuMan.createActionItem "uMax_snapVertsToGrid" "uMax"
 	snapVertsToGridItem .setTitle "Snap verts to grid"
 	snapVertsToGridItem .setUseCustomTitle true
 	menu.addItem snapVertsToGridItem 0
 
 	snapObjsToGridItem = menuMan.createActionItem "uMax_snapObjsToGrid" "uMax"
 	snapObjsToGridItem .setTitle "Snap objects to grid"
 	snapObjsToGridItem .setUseCustomTitle true
 	menu.addItem snapObjsToGridItem 0
 	
 	
 	-- Create a new sub menu:
 	subMenu = menuMan.createMenu "UU Grid Settings"
 
 	-- create the menu items:
 	subItem4 = menuMan.createActionItem "uMax_SetGridTo_4" "uMax"
 	subItem4.setTitle "4 UU"
 	subItem4.setUseCustomTitle true
 
 	subItem8 = menuMan.createActionItem "uMax_SetGridTo_8" "uMax"
 	subItem8.setTitle "8 UU"
 	subItem8.setUseCustomTitle true
 
 	subItem16 = menuMan.createActionItem "uMax_SetGridTo_16" "uMax"
 	subItem16.setTitle "16 UU"
 	subItem16.setUseCustomTitle true
 
 	subItem32 = menuMan.createActionItem "uMax_SetGridTo_32" "uMax"
 	subItem32.setTitle "32 UU"
 	subItem32.setUseCustomTitle true
 
 	subItem64 = menuMan.createActionItem "uMax_SetGridTo_64" "uMax"
 	subItem64.setTitle "64 UU"
 	subItem64.setUseCustomTitle true
 
 	subItem128 = menuMan.createActionItem "uMax_SetGridTo_128" "uMax"
 	subItem128.setTitle "128 UU"
 	subItem128.setUseCustomTitle true
 
 	subItem256 = menuMan.createActionItem "uMax_SetGridTo_256" "uMax"
 	subItem256.setTitle "256 UU"
 	subItem256.setUseCustomTitle true
 
 	-- Add the item to the menu
 	subMenu.addItem subItem4 -1
 	subMenu.addItem subItem8 -1
 	subMenu.addItem subItem16 -1
 	subMenu.addItem subItem32 -1
 	subMenu.addItem subItem64 -1
 	subMenu.addItem subItem128 -1
 	subMenu.addItem subItem256 -1
 
 	-- Create a new menu item with the menu as it's sub-menu
 	subMenuItem = menuMan.createSubMenuItem "Set grid to 64 UU" subMenu
 	menu.addItem  subMenuItem 0
 
 	--Add a separator again:
 	menu.addItem  (menuMan.createSeparatorItem()) -1
 )