Containers and MaxScript

I know nobody really likes containers, but I’m kinda in a position where I have to use them. I’m running into an interesting problem (and by “interesting,” I mean infuriating). The “Edit In Place” button is laughing at me. How do I set that button’s state with MaxScript? I see nothing in the docs, and really need to make sure that all containers in the scene have that button’s state set to “unchecked.”

Any advice?

You might want to look at DialogMonitorOps and UIAccessor.

Here’s an example I have written before for something!


(
	clearlistener()
	DialogMonitorOPS.unRegisterNotification id:#eyeInTheSky
	frmSaveFileDialog = dotNetObject "System.Windows.Forms.SaveFileDialog"
	
	fn checkfilesave ipath ifile =
	(
		fpath = ipath + ifile
		result = getFileAttribute fpath #readonly
	)
	
	fn dmnotification = 
	(
		 WindowHandle = DialogMonitorOPS.GetWindowHandle()
		-- Window info, for debbuging only
		/* format "Dialog Window Handle: %
" WindowHandle
		 format "Dialog Name: %
" (UIAccessor.GetWindowText WindowHandle)
		 format "Window Class Name: %
" (UIAccessor.GetWindowClassName WindowHandle)
		 format "Window Resource ID: %
" (UIAccessor.GetWindowResourceID WindowHandle)
		 format "Is Window: %
" (UIAccessor.isWindow WindowHandle)
		 format "Window DLL Filename: %
" (UIAccessor.GetWindowDllFileName WindowHandle)
		 format "Window DLL Description: %
" (UIAccessor.GetWindowDllDescription WindowHandle)*/

		if (UIAccessor.GetWindowText WindowHandle) == "Confirm Save As" then -- file overwrite info dialog
		(

			parent = UIAccessor.GetParentWindow WindowHandle
			controls = windows.getChildrenHWND parent

			fpath = ""
			ffile = ""			
			for i in controls do
			(
				case i[4] of
				(
					"ToolbarWindow32":if i[5] != "" then fpath = substitutestring i[5] "Address: " ""
					"Edit":ffile += i[5]
				)
			)
			fpath += @"\"
			rrfile = checkfilesave fpath ffile
			if rrfile == true then
			(
				ipath = fpath + ffile
				setFileAttribute ipath #readonly false
				/* File exists and is read-only - do your stuff here */
				setFileAttribute ipath #readonly true
			)
			else 
			(
				/* file exists and it's not read-only - do your stuff here */
			)
		)
		
		if (UIAccessor.GetWindowText WindowHandle) == "Save As" then -- main dialog and error dialog - they have the same caption
		(
				controls = windows.getChildrenHWND WindowHandle
				nbuttons = for  i in controls where i[4] == "Button" collect i
				if nbuttons.count == 1 then -- file save error dialog it shows even though we did set the file attribute not to be read only, so we just want to close this
				(
					UIAccessor.CloseDialog  WindowHandle
					parent = UIAccessor.GetParentWindow WindowHandle -- now that we're done, we can also close the main dialog
					UIAccessor.CloseDialog  parent
					DialogMonitorOPS.UnRegisterNotification id:#eyeInTheSky					
				)
		)				
		--format "=====================
"
		true
	)

	DialogMonitorOPS.RegisterNotification dmnotification id:#eyeInTheSky

	DialogMonitorOPS.Enabled = true
	DialogMonitorOPS.ShowNotification()
	
	
	frmSaveFileDialog.Filter = "SMDExporter (*.smd)|*.smd"
	
	dlgResult = dotNetClass "System.Windows.Forms.DialogResult"
	if frmSaveFileDialog.ShowDialog() == dlgResult.OK then
	(
		/*  file doesn't exist - do your stuff here */
		print frmSaveFileDialog.Filename
	)
		
)

That seems like a really long way to go… And the difficult part is that I don’t think the containers have a dialog that I can monitor. There’s the rollout that shows up in the Modify panel.

I’ll have to keep an eye on the dialogMonitor and UIAccessor, though. I’m thinking that will have its uses down the road. On the other hand, as a solution for now, I’ve found the action manager and the associated command:

actionMan.executeAction -1172021248 “13”

Extremely esoteric and completely non-intuitive, but this “hits the button” to turn on and off container edit mode on a selected container.