Disabling 'Avoid Overlap' switch on UVW Editor window?

Disabling 'Avoid Overlap' switch on UVW Editor window?

Anonymous
Not applicable
956 Views
1 Reply
Message 1 of 2

Disabling 'Avoid Overlap' switch on UVW Editor window?

Anonymous
Not applicable

Has anyone found a way to turn off the 'Avoid Overlap' checkbox in the 'Edit UVWs' window that was added in 2017? If this box is checked, it causes your Peel operations to re-UV the entire mesh. This is a major deal for us, because we've built an auto-UV tool that relies entirely on using Peel. The tool works great in 2016, but we can't adopt 2018 without the ability to disable that setting, since it nukes the entire meshes' UVs whenever we try to peel via script. I don't know of a way to actually read the state of the checkbox via the UIAccessor script classes; otherwise I would try that. If the solution is only exposed via the SDK, that might be acceptable too, as long as I can force that setting off. If anyone has any ideas, they'd be much appreciated - thanks folks!

 

avoidOverlap.JPG

0 Likes
Accepted solutions (1)
957 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Found a workaround for this! I remembered that not too long ago I had to figure out how to send a value to a Max UI spinner that was likewise not exposed to script, and I could use that as the basis for the solution here. It's hacky and totally horrible, but c'est la Maxscript, I suppose.

 

Assuming you have an object 'obj' with an Unwrap_UVW modifier on it, and the editor window is already open:

 

(
	local uvwEditorHwnds = UIAccessor.GetChildWindows obj.Unwrap_UVW.EditorHwnd
	local autoPackCheckBox = (for hwnd in uvwEditorHwnds where (UIAccessor.GetWindowResourceId hwnd == 45336) collect hwnd)[1]
	
	if (autoPackCheckBox != undefined) then
	(
		local BM_SETCHECK = 0x00f1
		local BST_UNCHECKED = 0x0000
		Windows.SendMessage autoPackCheckBox BM_SETCHECK BST_UNCHECKED 0
		UIAccessor.CloseDialog obj.Unwrap_UVW.EditorHwnd
		obj.Unwrap_UVW.Edit()
	)						
)

Checking the SDK documents, the checkbox for the 'auto pack' option (labeled in the UI as 'avoid overlap') has a fixed resource ID of 45336, so we need to find that Hwnd child of the UVW Editor window. We can use the Windows messaging system to send a 'uncheck' message to that button, which will always force the button off (i.e. it's not just a toggle operation, the checkbox will always wind up in the clear/unchecked state afterwards.) However, there is a wrinkle - as soon as the UVW Editor window regains focus, the state will immediately reset to whatever the previous state was (so the message we pass it evidently only changes the visual state, not the underlying viewmodel-equivalent state underpinning it.) If we close the UVW Editor window immediately, though, that seems to bake down the value of the view, as the next time we open up the window, it will have our desired value of 'unchecked'. Maybe one day we'll be able to just toggle this off via a simple boolean property on the modifier, but until then I hope this helps someone else!

0 Likes