Notifications
Clear all

[Closed] A couple questions about when construct usage

For now I guess I’m stuck with using

when transform nodes change handleAt:#redrawViews do
(
if mouse.buttonStates[1] == false do
format "% transform changed
" selection[1]
)

Unfortunately, this will only pick up user driven changes in transformations, not anything caused by a script

Look in the Maxscript help for info on parameter block event handlers.

Look in the Maxscript help for info on parameter block event handlers. Try using the “parameters” attribute in your when construction rather than “transform” as “parameters” will catch any changes to the object.

I’ve tried it with both transform and parameters, that part doesn’t make much of a difference as far as that goes.

I can’t find anything useful in the maxscript documentation on parameter block event handlers.

Also, I tried putting this in my parameters definition:


		on nodes tabChanged change do
		(
			if change == #refDeleted and ownerDeleteHandler != undefined do
			(
				owner = (refs.dependentNodes (custAttributes.getOwner this))[1]
				delete owner
			)

			for n in nodes where n != undefined do
			(
				when parameters n change handleAt:#redrawViews obj do
				(
					if mouse.buttonStates[1] == false do
						format "% parameters changed
" obj
				)
			)
		)
	) -- end parameters

Works fine initially, but if I delete and undelete a node, it stops working.

what do you mean by “driven by a script”? in time? animated by a controller? in this case you have to use controller. when construct is not for that.

Yeah, you’re right. You know, I… don’t even know any more. I’m too burned out too think clearly. Using the selection is fine for what I need. Just forget I mentioned it -___-

1 Reply
(@denist)
Joined: 2 years ago

Posts: 0

look at this snippet… i might help

delete objects
b = dummy name:#master 
in b (global p = point name:#p pos:[20,0,0] wirecolor:orange)
c = b.pos.controller = Position_List()
s = c.available.controller = Position_Script()
s.addobject "pos_monitor" p.pos.controller
s.setexpression "print pos_monitor.value; [1,1,1]"

Parameter event handlers are handlers like:
on … set … do
on … get … do

Sorry I wasn’t much help.

I’ll look into it a bit more tomorrow. I tried it earlier and it crashed Max when I tried to delete something, and I was thinking “no, not going through this again…” However I tried it again just now and haven’t been able to replicate the problem from earlier, so it was likely some other thing that was responsible.

Page 2 / 2