Does anyone know how to clone an existing panel? Down below there is a partial solution from Jakemoyo ( thanks!), using a popover. But I don't want a popover, I want the original layout, just cloned. Any ideas?
Original question:
I have a problem that is driving me mad: I try to duplicate an existing panel for convenience (in my case the vertex group panel) and I simply can't find a way to do it.
What I tried: found the source, which in my case is the following:
class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
bl_label = "Vertex Groups"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
engine = context.engine
obj = context.object
return (obj and obj.type in {'MESH', 'LATTICE'} and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
ob = context.object
group = ob.vertex_groups.active
rows = 3
if group:
rows = 5
row = layout.row()
row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows)
col = row.column(align=True)
col.operator("object.vertex_group_add", icon='ADD', text="")
props = col.operator("object.vertex_group_remove", icon='REMOVE', text="")
props.all_unlocked = props.all = False
col.separator()
col.menu("MESH_MT_vertex_group_context_menu", icon='DOWNARROW_HLT', text="")
if group:
col.separator()
col.operator("object.vertex_group_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
if (
ob.vertex_groups and
(ob.mode == 'EDIT' or
(ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex))
):
row = layout.row()
sub = row.row(align=True)
sub.operator("object.vertex_group_assign", text="Assign")
sub.operator("object.vertex_group_remove_from", text="Remove")
sub = row.row(align=True)
sub.operator("object.vertex_group_select", text="Select")
sub.operator("object.vertex_group_deselect", text="Deselect")
layout.prop(context.tool_settings, "vertex_group_weight", text="Weight")
I could copy paste the whole code generating this panel in my own code, but that seems overkill. Is there a better way to reference from the existing code? I mean, in case of an operator it's easy (pseudo code):
row.operator("my_addon.my_custom_operator_from_bpy.ops.blabla", text="do whatever")
I am aware of:
Copy existing property from e.g. Properties window to a custom panel
Is there a way to get custom properties panel in a custom t panel?
How to draw Blender's default panel in Operator draw function?
But those solutions are for some custom props, which are not the issue. I need the whole panel.
Thank you for your help!