1
$\begingroup$

When I create a string property for the object type, I can modify that property in the active object. But when I create another string property for the f-curve type, it said it is read-only.

The script:

import bpy
bpy.types.Object.objprop = bpy.props.StringProperty(name = "objString")
bpy.context.object.objprop = "mod_objString"

bpy.types.FCurve.fprop = bpy.props.StringProperty(name = "fString")
bpy.context.object.animation_data.action.fcurves[0].fprop = "mod_fString" # error occured on this line

error:

error

some testing in the built in python interpreter:

in built in python interpreter

Edit: The blend file (although it is almost empty but just in case):

$\endgroup$
1
$\begingroup$

Assigning to Existing Classes

Custom properties can be added to any subclass of an ID, Bone and PoseBone

Neither are bones, so leaving that aside, can see below ID is subclass of Object not FCurve, and as such is the property is not "wired up" as a property on the fcurve.

>>> issubclass(bpy.types.Object, (bpy.types.ID,))
True

>>> issubclass(bpy.types.FCurve, (bpy.types.ID,))
False

another test for this would be trying to assign ID properties to an instance. This is how a non default value of a property is stored in blend file.

For example, for an Object type

>>> C.object["foo"] = 1

but not for an FCurve

>>> D.actions['CubeAction'].fcurves[0]
bpy.data.actions['CubeAction']...FCurve

>>> D.actions['CubeAction'].fcurves[0]["foo"] = 1
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct[key] = val: id properties not supported for this type
$\endgroup$
2
  • $\begingroup$ thanks, so is there other ways I could store properties in individual fcurves? $\endgroup$
    – covector
    Feb 8 '20 at 8:53
  • 2
    $\begingroup$ Off top of head could use collection property on action. Give item a datapath and array_index to lookup from FCurve. $\endgroup$
    – batFINGER
    Feb 8 '20 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.