Notifications
Clear all

[Closed] How to addnewkey to a newly defined custom attribute??

Hi,

I am trying to add a new key to a custom attribute but my script doesnt work.

The new parameter block (Amyface) has got one track called CNT_Teapot01_1_Position_XYZ

This doesnt seem to work:

addnewkey $.modifiers[1].Amyface.CNT_Teapot01_1_Position_XYZ.controller 0f

but I cant workout why, the listener just returns:

– No ““addNewKey”” function for undefined

[color=white]Does anyone understand why this happens?[/color]

Thanks

Spencer

8 Replies

did you assign a controller to that parameter?

try
$.modifiers[1].Amyface.CNT_Teapot01_1_Position_XYZ.controller = position_xyz()
addnewkey $.modifiers[1].Amyface.CNT_Teapot01_1_Position_XYZ.controller 0f

No thats not working either. I changed your code slightly but when I run this:

$.modifiers[1].Amyface[1].controller = position_xyz()

…to assign a controller the listener returns:

– Runtime error: Cannot set controller

This is actually what I am ultimately trying to achieve (adding different controllers to multiple tracks through scripting) but only the type:#float parameters are working at the moment.

I realised that if I manualy add a key in dope view to the above mentioned track, I can then set an appropriate controller through scripting, I guess when you add a key through dope view it must automtically set a ontroller to allow it to recieve the key…?

Any other ideas?

try adding a bezier_point3() controller instead of a position_xyz() controller since your not applying a controller to a position track

Hi Joel,

Because of what I am doing I have to apply the positionXYZ controller to the attribute track (which was created as type:#point3) since the script has to work its way through more than one of these automatically. My script is taking tracks from a list of objects and then instancing them into the relevant tracks in the self generated list of new attributes. I am just breaking down my problem into little bits so it is easier for me to exlpain.

I have since found out that the ‘Position_Rotation_Scale’ controller is a type:#matrix3 controller which is not animatable and therefore will not be added as a new track using:

[color=orange]—An attribute holder mod must be added on the selected object as the first mod
def=attributes Amyface
(
parameters faceP
(
CNT_Sphere01_1_Position_XYZ type:#matrix3
)
)
custAttributes.add $.modifiers[1] def

[/color]———————–
The attribute will however show in the attribute definition, if you open it as a new script you will see it.

I have also found out that type:#quat is not supported which means I can’t create a definition/track to instance EulerXYZ controllers onto.

Has anyone successfully instanced a EulerXYZ controller from an object into a new ca track?..I assume this is not possible…?

Thanks

Spencer

1 Reply
(@magicm)
Joined: 11 months ago

Posts: 0

Like Gravey said, you cannot apply a positionXYZ controller to these tracks. An alternative (which is also a compound controller containing 3 separate float tracks for X, Y and Z) is a Point3_XYZ controller.

-- Apply Point3_XYZ controller
$.modifiers[1].Amyface.CNT_Sphere01_1_Position_XYZ.controller = Point3_XYZ()
-- Create a key at frame 0
addNewKey $.modifiers[1].Amyface.CNT_Sphere01_1_Position_XYZ.controller 0f
-- Get the value of the first key in the X track of the Point3_XYZ controller
$.modifiers[1].Amyface.CNT_Sphere01_1_Position_XYZ.controller[1].controller.keys[1].value

Here’s a way to instance the entire transform controller of an object to a custom attributes track. The trick here is to use a #maxObject parameter. This could be used to instance any other type of controller (or any maxObject actually) as well.

(

-- create a test object and apply the attribute holder modifier
Teapot isSelected:true
addModifier $ ('PEN_Attribute_Holder 2'())

-- attribute definition
local def = attributes Amyface
(
	parameters faceP
	(
		CNT_Sphere01_1_Transform type:#maxObject
	)
)

-- add the custom attributes to the test object
custAttributes.add $.modifiers[1] def

-- store the object's transform controller
$.modifiers[1].Amyface.CNT_Sphere01_1_Transform = $.transform.controller

)

Cheers,
Martijn

Hi Matijn,

Thanks for your reply. The trouble is when I apply the ca to my object with:

– attribute definition
local def = attributes Amyface
(
parameters faceP
(
CNT_Sphere01_1_Transform type:#maxObject
)
)

– add the custom attributes to the test object
custAttributes.add $.modifiers[1] def


…the new attribute doesnt appear in track view as a track – whereas if you apply the exact same script to the object only with type:#float it does appear as a new track…

…doesn’t this then mean that although there are no error messages in doings so, instancing tracks to these attributes has no effect…?

Like type#matrix3, maxobject is not listed as animatable in the help.

1 Reply
(@magicm)
Joined: 11 months ago

Posts: 0

Unlike #float, #integer etc. the #maxObject type does not per se contain an animatable value. For instance you could even assign the current renderer to the parameter:

$.modifiers[1].CNT_Sphere01_1_Transform = renderers.current

When you assign the transform track of the object:

$.modifiers[1].CNT_Sphere01_1_Transform = $.transform.controller

you are actually instancing the transform controller into the ca parameter directly, and not in its .controller property, like you would with (for example) a #float (this example assigns the position X controller to the ca param):

$.modifiers[1].CNT_Sphere01_1_SomeFloatParam[b].controller[/b] = $.position.controller[1].controller

Simply try changing any of the parameters from the ca:

-- store the current render in the ca param
$.modifiers[1].CNT_Sphere01_1_Transform = renderers.current
-- assuming the current renderer is set to scanline:
$.modifiers[1].CNT_Sphere01_1_Transform.shadows = false

Now when you open the render dialog, you’ll see that shadows are now turned off.

Martijn

I think I understand. Really I need to be able to access the keys on these tracks but then I guess you wouldn’t usually add keys to the transform track, you would set keys individually to rotation, pos, scale or whatever.

I am still a bit miffed as to how you cannot create a new attribute for something like a EulerXYZ.controller (which is classOf type:#quat) to be instanced into since #quat is not a supported type of attribute…

I am going to have a little rethink about my approach to this script, thanks everyone for all your help, it is very much appreciated!!!

Kind Reagrds

Spencer