1
$\begingroup$

I am trying to create an add-on to create parametric objects (Blender 2.8rc1)

I have defined a custom PropertyGroup, i.e.:

def _update(self, context):
    print(repr(self))

class FurnigenProperties(types.PropertyGroup):
    width: FloatProperty(
        update=_update,
        unit='LENGTH'
    )
    length: FloatProperty(
        update=_update,
        unit='LENGTH'
    )

When I change property I can see out of _update:

bpy.data.objects['GeneratedObject'].parametric_properties

What I essentially want to get access to would be bpy.data.objects['GeneratedObject'] however I am unclear how to get from self in callback function to actual object that property we just modified.

Looking at documentation for bpy.props.FloatProperty there isn't much detail on what I should expect context to be.

I.e. would context be the place to retrieve object reference? I was thinking about context.object, but I am not clear how object is determined. Is that object selected by user in viewport? In which case it wouldn't work if I modified property from some other Python code (as it would be most likely for a collection of objects of which none would be selected by user). Or is context.object in callback guaranteed to point to object that self belongs to in above callback?

edit:

context.object doesn't seem to work. I just tried setting value of one of my properties through Python console and the object that I get from context.object is (as I expected) object selected in viewport and not the object I modified property of.

$\endgroup$
1
$\begingroup$

id_data

the id_data property of any blender object is a refernce to the ID type object it belongs to.

def _update(self, context):
    print(self.id_data)
$\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.