Hi,
I am interested in adding a new opperator to the Background Images Panel in the View3d Properties area. Is it possible to do this with an add-in? I know that I can do it by editing the relivant python code already in the Blender release, but I would prefer to have my add-in modify that panel so that I can keep all of the code together rather than tweeking stuff in the .py files that are part of the blender release.
you can append / prepend to the draw method of the existing panel. Get its class using “view_source” when you right click on prop in that panel. For background images Panel
import bpy
def extra_button(self, context):
layout = self.layout
layout.operator('some.operator') # change this to a real operator.
bpy.types.VIEW3D_PT_background_image.append(extra_button)
Another method I like is to override the draw method.
Here I display my own custom draw for the 3dview header, when some condition is met, otherwise display the default.
import bpy
from bl_ui.space_view3d import VIEW3D_HT_header as ov3d
f = ov3d.draw
def preview_view_draw(self, context):
if some_condition:
custom_draw(self, context)
else:
# revert to default
f(self, context)
def register():
bpy.types.VIEW3D_HT_header.draw = preview_view_draw
def unregister():
bpy.types.VIEW3D_HT_header.draw = ov3d.draw