4
$\begingroup$

Hi I am trying to use the set method for a property. Thats how I try to use it:

def set_coa_sprite_frame(self,value):
    self.coa_sprite_frame = value

bpy.types.Object.coa_sprite_frame = IntProperty(
        description="Frame",
        default=0, min=0, max=10,
        set=set_coa_sprite_frame)

But I get a maximum recursion depth error. Whats the problem? Do I use it incorrectly?

$\endgroup$
5
$\begingroup$

The property set callback is intended to be used when you need to store the value in some alternate location (a set callback could write to multiple other properties for example - store the data on disk... a JSON, XML data... whatever you like).

Using both the get/set callback, you can expose access to settings stored outside of Blender.

Assigning the value within the set callback, causes infinite recursion.

So, either:

  • use the set callback to write to a different location.
  • use the update callback instead, to perform some change after the value is set.

Or, if you really want, you can write to the underlying property store directly, however this relies on an implementation detail on how properties work. While we don't intend to change this part of the API (which would break scripts)... its better to avoid this.

eg:

def set_coa_sprite_frame(self, value):
    self["coa_sprite_frame"] = value
$\endgroup$

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.