Notifications
Clear all

[Closed] ProBoolean and it's Undo

here is a simple scene setup for ProBoolean test:

delete objects

a = box()
ProBoolean.SetOperandA a

b = cylinder()
select a
gc()

try next step and check undo stack

undo "Add B" on
(
	ProBoolean.SetOperandB a b 2 1
)
-- undo stack #("Add B") 

this is correct

undo all…

now try this:

undo "Add B" on
(
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
)
-- undo stack #("Create") ? 

it’s a little strange but still OK because one operation in stack.

undo all…

now:

undo "Add B" on
(
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	ProBoolean.SetOperandSel a 1 on
)
-- undo stack #("Create", "Edit Values") ??

this is bad, because two operations in stack.

undo all…

and:

undo "Add B" on
(
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	ProBoolean.SetOperandSel a 0 off
	ProBoolean.SetOperandSel a 1 on
)
-- undo stack #("Create", "Edit Values", "Edit Values") ???

this is very bad…

i have no idea how to defeated this behavior. it tried everything. i’ve played with theHold… it works different but still doesn’t correct.

any ideas?

24 Replies

Not an elegant workaround, but this seems to wrap the whole thing in 1 undo entry.
Basically, add 1 undo context for each SetOperand() entry.
I just tested with your code, perhaps with other operations it works different.

undo on undo on undo on
(
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	ProBoolean.SetOperandSel a 0 off
	ProBoolean.SetOperandSel a 1 on
)

Edit:
This also seems to work:

undo on
(
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	undo off
	(
		ProBoolean.SetOperandSel a 0 off
		ProBoolean.SetOperandSel a 1 on
	)
)

Well – it seems serious undo problems are all shared across the whole nPowerTools Products ( where ProBooleans stems from )
Testing the PowerNurbs Demo revealed pretty serious incompleteness regarding undoable operations …
No experience with the scripting part though …

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

yes. they work with theHold wrong.

it doesn’t really works:
#1 I want to have only one and my undo title in the stack
#2 undo/redo has toggle between exactly same states

in your solution the undo title is “Create”, and after undo/redo the last operand is not selected as was set in the code

1 Reply
(@polytools3d)
Joined: 11 months ago

Posts: 0

Yes, neither codes keeps the Title in the Undo stack. That’s why I didn’t use it.
Does the first code work? (the one with multiple undo entries)

not exactly right. it makes only one entry in the stack, but the name of it comes from ProBoolean, and after undo/redo it loses operators selection. (it has to keep the last operand selected)

(
	theHold.SuperBegin()
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	ProBoolean.SetOperandSel a 0 off
        ProBoolean.SetOperandSel a 1 on
	theHold.SuperAccept "Add B"
)

in theory this has to work, but it doesn’t

(
	theHold.SuperBegin()
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	ProBoolean.SetOperandSel a 0 off
	theHold.SuperAccept()
	undo "Add B" on ProBoolean.SetOperandSel a 1 on
)

this is pretty close to what i want, but undo/redo doesn’t work right anyway

1 Reply
(@polytools3d)
Joined: 11 months ago

Posts: 0

This does the same as your second code, it shows the correct label in the Undo Stack. Redo still does not work correctly.

(
	theHold.Cancel()
	theHold.SuperBegin()
	ProBoolean.SetBoolOp a 4
	ProBoolean.SetOperandB a b 2 1
	ProBoolean.SetOperandSel a 0 off
	ProBoolean.SetOperandSel a 1 on
	theHold.SuperAccept "Add B"
)

Ok, a little progress. Ugly but Redo seems to work.

fn GetProBooleanListboxHWND =
(
	getID = uiaccessor.getwindowresourceid
	children = windows.getchildrenhwnd #max
	
	-- ID 1042 in Max 2014
	for j in children where j[4] == "ListBox" and getID j[1] == 1042 do return j[1]
	return undefined
)

(
	max modify mode
	
	WM_LBUTTONDOWN = 0x0201
	WM_LBUTTONUP   = 0x0202
	
	listHWND = GetProBooleanListboxHWND()
	
	if listHWND != undefined then
	(
		theHold.Cancel()
		theHold.SuperBegin()
		
		ProBoolean.SetOperandSel a 0 on

		windows.sendMessage listHWND WM_LBUTTONDOWN 0 0
		windows.sendMessage listHWND WM_LBUTTONUP 0 0
		
		ProBoolean.SetBoolOp a 4
		ProBoolean.SetOperandB a b 2 1
		ProBoolean.SetOperandSel a 0 off
		ProBoolean.SetOperandSel a 1 on
			
		windows.sendMessage listHWND WM_LBUTTONDOWN 0 0
		windows.sendMessage listHWND WM_LBUTTONUP 0 0

		theHold.SuperAccept "Add B"
	)else(
		messagebox "No HWND. Do a better job next time"
	)
)

Perhaps you can get it to work without the Modify Panel opened.

you are following my trail… next step is to hit exactly right item. you are hitting the first

Just checked the ProBooleans Listbox ID is the same (1042) from Max 2011 to 2017.

I don’t understand what you mean.
Isn’t the second models the one that should be selected?

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

when you send message ‘mouse down/up’ to listbox you simulate mouse click event.
LParam of the message is mouse-click position. in your case it’s 0. that means you click the first item in the list (click position 0,0).

(@polytools3d)
Joined: 11 months ago

Posts: 0

Would you please try the code I posted above. Regardless of the values that needs to be passed in the parameters, it seems to work from Max 2011 to 2017. Trust me, I tested it. (at least with the sample models you proposed for testing)

Page 1 / 2