How To Add Custom Property To Node?

Hi,

I’d like to add a custom Property to a RotoNode. More specifically, another number slider, like the motionblur sample Property.
I see in the Documentation there’s some info hinting towards use for “user defined” properties, but there’s no info on creating them (that I can find). If I try:

prop = fx.Property("test", "test")

I get no errors for the creation of the Property, but then I cannot set its value, type or anything.
I tried to .clone() the motionblur.sample Property, but it doesn’t support cloning.
Any info or examples of working with custom Property’s would be greatly appreciated!

Thanks,
Corin

You need to add the property to an object to get it to show up.
Typically you would register a object_created hook, so when the object type you are interested in gets created, you get called back, then you create/add the custom properties.

Here is an example:

import hook

def object_created_hook(object):
	if object.isType("Shape"):
		p = Property(id="foo", label="Foo!", value=0.0, info = { "min":0.0, "max": 100.0 })
		object.addProperty(p)

hook.add("object_created", object_created_hook)

That’s working nicely now, thanks Paul!

Yes, I knew to add the property to the object, it was just figuring out what args it took I couldn’t get, but your example was perfect for that!

Cheers,
Corin