Do I have to fork blender to add object types?

I was wondering whether it might be possible to use the Python API to add a type of object I need for game environment development. It’s sort of like an empty with snapping behaviour. I could perhaps just add behaviour to a standard empty, but I wonder if someone can point me to a document which discusses the limitations of the API clearly for someone who has no experience with Blender scripting.

No, it is currently not possible to define custom object types through API sadly. A fork is an option, but it adds a lot of extra responsibility for you to keep your fork up to date with official Blender changes.
I am also developing an addon which is a model/level editor for a game engine, and I know the nature of that problem very well when you need custom object types.

This is the list of solutions to different problems that I came up with so far:

  1. Game engine object types are defined with bpy.props.PropertyGroup classes, aka custom properties for ID objects / Bones. The property group contains all the game engine data I need to store such as different parameters. Each property group defines the “enabled” bpy.props.BoolProperty to identify that this object is of this particular game engine object type. Panels drawing these are defining poll() methods to make them appear mutually exclusive. In my case, “enabled” property is not exposed to the GUI.

  2. I defined a set of bpy.props.CollectionProperty() acting as a sort of outliner for game engine objects. You can add/remove them automatically using a depsgraph_update_post() handler tracking changes to scene / objects / materials or whatever you need. Your custom snapping behavior could be added through that very handler.

This is especially convenient if you are developing and exporter, since Objects are pre-sorted by categories before export, so the exporter code does not need to filter the entire scene for them. Just loop over your custom collections. Less time the 3D artist is waiting on the export result, the better.
If you want to see implementation for that, hit me a PM.


Thank you for the rich reply, I just started learning Python scripting this morning (C++ native), so I don’t fully understand the syntax or structure but luckily the function I need is quite simple, I would be surprised if I couldn’t do the same as you and add a bunch of custom properties and some scripts which act on those properties when needed.

It is a shame that custom objects can’t be added, I am used to the Unreal API which is very open by comparison. Perhaps one day they can add the ability to create a subclass of an existing object if not creating types outright.

Is the goal here to re-create UE4-style sockets in Blender, or to improve socket creation/management for export?

No, it’s a bespoke system that will help me with some procedural generation in the engine. It’s mostly to help with the creation aspects, but also to hold some data for export as well.