I am creating an add-on that extends the functionality of the default .fbx file importer. I want to use a lot of the user interface for importing a file, so I am inheriting a lot of the classes from the .fbx importer add-on. You can see an example of that here:
This works, but I am getting the following warning every time the panel is drawn:
WARN (bpy.rna): C:\Users\blender\git\blender-v360\blender.git\source\blender\python\intern\bpy_rna.c:8422 bpy_class_call: unable to get Python class for RNA struct 'FBX_PT_import_include'
I am not able to find much information on this warning. What does it mean and how do I fix it?
Thank you for any help. I very much appreciate it.
It seems like it is possible, though it doesn’t necessarily work exactly how you expect.
Instead of creating a custom panel that inherits from a predefined panel they want you to create an abstract class with all your custom info, then create a standard panel that inherits from your abstract class and bpy.types.Panel.
From one of the links (though others suggest putting the mixin class before the Blender class):
class CommonProps:
s = StringProperty(name="s",default="ABC")
class Base(bpy.types.PropertyGroup, CommonProps):
pass
class Child(bpy.types.PropertyGroup, CommonProps):
pass
I get what you are saying here with the mix-in classes. Looking at your example, it really wouldn’t work for my scenario. The base class I am trying to use is a part of a separate add-on. I don’t have the ability to change the class. Is that the only option or is there another way to make this work? Thanks.
Just to iterate, you can’t subclass most blender API python classes, but you can use multiple inheritance to add custom behaviour to your classes. eg if you want to define a specific poll method for all your panels.
class MyPanelBase:
@classmethod
def poll(cls, context):
return context.object and context.object.type == "MESH"
class MyPanelLocation(bpy.types.Panel, MyPanelBase):
def draw(self, context):
self.layout.prop(context.object, "location")
class MyPanelScale(bpy.types.Panel, MyPanelBase):
def draw(self, context):
self.layout.prop(context.object, "scale")
This example won’t work out of the box but it’s here to illustrate with a practical example.
I would just suggest a bit of caution, if you disable your addon the panel might not work correctly anymore, or throw errors in the console, you can store the previous poll method somewhere and re-assign on unregister.