# Inheritance of objects

With bpy, how could I make a subclass of an Object and use it ?

I made a subclass of bpy.types.Object, but I don't know how to add it to my scene. The only way I know to add objects is using bpy.data.objects.new.

But I don't see any way of adding a subclass.

As the Blender Documentation states:

Those of you familiar with other Python API’s may be surprised that new data-blocks in the bpy API can’t be created by calling the class.

As you stated, that makes bpy.data.objects.new the only way to create new objects.

For my purposes, I created a new class which did not inherit from bpy.type.Object but defined a self.object property and initialized it with the new function. I then wrote all the methods I needed and modified self. object inside them.

I defined one base class, and then one additional class for cameras, lamps and objects:

class ExtendedObject():
def __init__(self,name,  obj, loc):
self.name = name
self.object = obj
self.object.location = loc