Notifications
Clear all

[Closed] Custom attribute script evaluation?

I have an object whose position/rotation/scale I need to modify with a float script. I want to keep things as clean as possible, so I would like the script to be stored somewhere in the object, rather than in another object that references it.

I can’t put the float script anywhere in the object’s position/rotation/scale tracks because that creates illegal self-references.

I tried putting the script in a custom attribute controller but it doesn’t evaluate automatically.

I did some reading and some people said to add a target in the script, to a subanim of another object in the scene, to trigger updates. But that’s messy and can easily break.

Is there any way to store an automatically-updateable (ie, it updates at each frame) script on an object, and have it modify the object’s position/rotation/scale controller values without creating illegal self references?

Note: The script involves accessing the transform values of the object, as well as its bounding box max/min values…so I can’t just put it in a list controller within the position/rotation/scale tracks. It absolutely needs to reside outside of any position/rotation/scale tracks.

7 Replies
1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

something like that:


global custTM = attributes custTM attribID:#(0x00001967, 0x6c10e7a1)
(
	fn timeChanged = if isvalidnode (node = refs.dependentNodes this firstonly:on) do animate off undo off
	(
		format "at time:% node:%
" currentTime node
		node.transform = translate (rotateYPRMatrix 0 0 currentTime) [node.pos.x,node.pos.y,currentTime]
	)
	on create do registerTimeCallback timeChanged
	on load do registerTimeCallback timeChanged
	on clone it do registerTimeCallback timeChanged
)
/*
b = box()
custattributes.add b custTM #unique baseobject:off
--custattributes.delete b (custattributes.getdefs b baseobject:off)[1]
*/

 PEN

Hmm, that is a tough one. Really, anything that is modifying the transforms needs to be on the transforms or it will not be called by the reference system. Every thing else is a bit of a cheat. One thing that I have done many times is a callBack system to force the updates when needed. This can cause over head how ever but if managed well can work very well. This project… http://www.penproductions.ca/technical/pinkyDinkyDoo/pinkyDinkyDoo.htm used that extensively and worked very well. I had a scripted Map plugin tied to a scripted modifier plugin that were updated via several callBacks as needed. The callBacks are added when the nodes load and are killed when removed.

Exactly what is it you are trying to do?

but we have to understand that the animation will not be visible at render time because it was made without direct changing of transform controller.

Thanks guys,

Yea I thought of doing a callback but the problem is that it won’t carry over if I merge the objects into another scene file or something. And also the animation does have to be visible at rendertime.

I guess I’ll go with one of the messier solutions…

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

i don’t think it should be too messy. i did it many times and it worked pretty well .

It’s not the most elegant way, but I’ve just managed to get something to work that might help.

I made a teapot and added a custom attribute to it:

theScr = $Teapot01.pos = [sliderTime,0,0]

Then I made a point helper, linked it to the teapot and changed it’s pos controller to script:

execute (getUserProp (refs.dependentNodes this firstOnly:on).parent "theScr")
[0,0,0]

This way you can store the script in the userprops of the actual object. And you can merge in the point helper with the object that it’s linked to.

Like I said, not the tidiest, but it might get you there.

Cg.

Or you could use this as the custom attribute if you don’t want to hard wire the object name

theScr = ((refs.dependentNodes this firstOnly:on).parent).pos = [sliderTime,0,0]

Cheers,

Cg.