[Closed] Proboolean problems in max 9
Can anyone else reproduce this, and tell me a way to correct it?
i’m basically trying to do some proboolean tasks with code, here is a cut down example of what i’m doing
(
ProBoolean.createBooleanObjects ($Plane01)($Box01) 2 2 0
ProBoolean.setCookieCut ($Plane01) true
a = ProBoolean.getCookieCut($Plane01)
print a
select $Plane01
)
though “a” will print true, the cookie checkbox is obviously false.
Does this happen to anyone else, and can anyone tell me what i can do to fix it? Basically i just want the box to cut a hole into the plane.
attached is an example file to test with.
looks like that’s broken – returns the correct values in 2010, at least, but it looks like there’s plenty of other issues with ProBoolean access (like changing the operation, removing a node, setOperandB throwing nothing but ** system exception ** etc. etc.) and an undo here just caused a crash
You might be able to use UIAccessor to toggle that checkbox, but that still leaves you with having to deal with other issues. I think it’s doable, but 3ds max 9 is lacking a few useful bits and pieces that would make it easier, too.
perhaps you could use Boolean2 instead?
Thanks for looking into it,
It seems it would just be easier to split my script up into 2 scripts then take the extra time to see if i can get the dialog Ops working. There’s not to much left to do after i do the boolean operation, so this will just be easier.
Thanks again for confirming.
no prob… in the mean time, this might help:
-- Function to get the 3ds Max HWND.
-- Note that it will return the last found 3ds Max 9 window, which may not be the
-- active one.
-- In 3ds Max 2008+, you would use windows.getMaxHWND()
fn getMax9HWND = (
local desktopChildrenHWNDs = UIAccessor.getChildWindows 0
local maxHWND = undefined
for i = 1 to desktopChildrenHWNDs.count do (
local windowTitle = UIAccessor.getWindowText desktopChildrenHWNDs[i]
if (matchPattern windowTitle pattern:"*Autodesk 3ds Max 9*") then ( maxHWND = desktopChildrenHWNDs[i] )
)
maxHWND
)
-- Find the command panel as a child of that 3ds Max HWND
-- This will fail if you float your command panel.
-- If you do float your command panel, see the above function as a template
-- to finding the "Command Panel" window as a child of the desktop.
fn getMax9CommandPanelHWND = (
local maxHWND = getMax9HWND()
if (maxHWND == undefined) do ( return undefined )
local maxChildren = UIAccessor.getChildWindows maxHWND
local commandPanelHWND = undefined
for i = 1 to maxChildren.count do (
local windowTitle = UIAccessor.getWindowText maxChildren[i]
if (windowTitle == "Command Panel") then ( commandPanelHWND = maxChildren[i] )
)
commandPanelHWND
)
-- find the "Cookie" checkbox as offspring of the Command Panel
fn getMax9ProBooleanCookieCheckboxHWND = (
local commandPanelHWND = getMax9CommandPanelHWND()
if (commandPanelHWND == undefined) do ( return undefined )
local commandPanelChildren = UIAccessor.getChildWindows commandPanelHWND
local cookieCheckboxHWND = undefined
for i = 1 to commandPanelChildren.count do (
local windowTitle = UIAccessor.getWindowText commandPanelChildren[i]
if (windowTitle == "Cookie") then ( cookieCheckboxHWND = commandPanelChildren[i] )
)
cookieCheckboxHWND
)
-- A function to set a checkbox state by HWND
fn setCheckboxState hwnd state = (
local parentHWND = UIAccessor.getParentWindow hwnd
local id = UIAccessor.getWindowResourceID hwnd
local state = case state of (
true: (BST_CHECKED = 0x0001)
false: (BST_UNCHECKED = 0x0000)
#indeterminate: (BST_INDETERMINATE = 0x0002)
)
UIAccessor.sendMessage hwnd (BM_SETCHECK = 0x00f1) state 0
if (state != #indeterminate) then (
UIAccessor.sendMessage parentHWND (WM_COMMAND = 0x0111) ((bit.shift (BN_CLICKED = 0x0000) 16) + id) hwnd
)
OK
)
-- the function to create a proBoolean cookie-cut subtraction.
-- subtracts B from A
-- will throw an error if it fails to find the necessary checkbox
fn cookiecutProBoolean a b = (
-- create an empty boolean first
proBoolean.createBooleanObjects a #() (subtraction = 2) (move = 2) (retainOriginalMaterial = 1)
-- select the boolean object
select a
-- and go to modify mode so we can find that cookie checkbox
max modify mode
-- now try finding it
cookieCheckboxHWND = getMax9ProBooleanCookieCheckboxHWND()
-- failsafe device below
if (cookieCheckboxHWND == undefined) do ( throw "Could not find Cookie checkbox!" )
-- toggle the checkbox
setCheckboxState cookieCheckboxHWND true
-- now set the B operand.
proBoolean.setOperandB a b (subtraction = 2) (retainOriginalMaterial = 1)
-- return the result
a
)
Edit: 0x000 -> 0x0000 ; has no actual impact (both are ‘zero’) but is the proper notation