Notifications
Clear all

[Closed] Param Block #Node runs function

If i have a paramblock that contains


TargetNode type:#node subAnim:false

How can I make it so a function is executed any time that TargetNode is manipulated by moving, rotating or scaling it or adjusting it’s parameters (width, height, length)?

There a way to do this?

6 Replies

hey John,

take a look at the help topic “change handlers and when constructs”

These are pretty cool.
Do you have any suggestions when using this? Are they known to be very unstable and buggy? If done right are they fine to use?


delete objects
box()
box()

a = $box001
b = $box002
when transform $box001 changes id:#UpdateNodes do
(
	b.position = random [-10,-10,0] [10,10,0]
	
)

deleteAllChangeHandlers id:#UpdateNodes 

I see you can assign these construct’s an ID to remove them.

Is there an easy way to keep them local to each node them selves? Rather than the ID name.
I don’t want to delete the ID because that then removes every ID in the scene rather than just one particular construct. Because I’ll be assigning this construct in a function to several different nodes.

see sample?


delete objects
box()
box()
cylinder()
cylinder()

a = $box001
b = $box002
when transform $box001 changes id:#UpdateNodes do
(
	b.position = random [-10,-10,0] [10,10,0]
	
)
a = $cylinder001
b = $cylinder002
when transform $cylinder001 changes id:#UpdateNodes do
(
	b.position = random [-10,-10,0] [10,10,0]
	
)

--deleteAllChangeHandlers id:#UpdateNodes 


If i were to run this through a for-loop and in a perfect world I would place a modifier on each set of objects allowing for me to remove the handle/callback. But how do I make it unique for each node?


-- delete objects

for i = 1 to 3 do
(
	a = box width:20 height:40 length:20
	b = box width:15 height:30 length:15
	c = box width:10 height:20 length:10

	when transform a changes id:#UpdateNode do
	(
		--b.position = random [-10,-10,0] [10,10,0]
		b.pos = [(a.center[1]),(a.center[2]),(a.max[3])]
	)
	when transform b changes id:#UpdateNode do
	(
		c.pos = [(b.center[1]),(b.center[2]),(b.max[3])]
	)
)

--deleteAllChangeHandlers id:#UpdateNode

 lo1

calling the when construct returns a handler object, which you can store in a variable.
You can then call deleteChangeHandler on this object.

myHandler = when transform a changes id:#UpdateNode do
(
	b.pos = [(a.center[1]),(a.center[2]),(a.max[3])]
)
deleteChangeHandler myHandler


Thanks guys for the help.