I want to get "Use Count" Panel to attach to My Panel, what should I do? I know its Class is "PARTICLE_PT_render_collection_use_count", as shown below. Hope to get help, Many Thanks!
Reuse the code.
Can turn on developer extras and view the source of most of blenders UI.
An option would be to copy the code needed and add to a new Panel class.
A rub is the properties area often has context members unique to the region. For this case
context.particle_system is defined in the properties area in particles tab.
Would instead need to be edited to
Monkey patching and passing context object with extra members.
As an example have given new panel a method which refers to blenders UI class draw method. A namespace object is used to create a context with the extra members and passed to the draw method as a proxy context object.
Similarly with the poll method of the
Could do same for
Have, however, simply added the use count property to the draw method, it could however be used in a draw header method to replace "Hello World" title.
import bpy from argparse import Namespace from bl_ui.properties_particle import ( PARTICLE_PT_render_collection_use_count, PARTICLE_PT_render_collection) class HelloWorldPanel(bpy.types.Panel): """Creates a Panel in the Object properties window""" bl_label = "Hello World Panel" bl_idname = "OBJECT_PT_hello" bl_space_type = 'VIEW_3D' bl_region_type = 'UI' @classmethod def poll(cls, context): ps = context.object.particle_systems.active c = Namespace(**context.copy()) c.particle_system = ps return PARTICLE_PT_render_collection.poll(c) # monkey draw_part = PARTICLE_PT_render_collection_use_count.draw def draw(self, context): layout = self.layout ps = context.object.particle_systems.active if ps: layout.prop(ps.settings, "use_collection_count") c = Namespace(**context.copy()) c.particle_system = ps self.draw_part(c) def register(): # fake a pin_id for 3d view. bpy.types.SpaceView3D.pin_id = None bpy.utils.register_class(HelloWorldPanel) def unregister(): del bpy.types.SpaceView3D.pin_id bpy.utils.unregister_class(HelloWorldPanel) if __name__ == "__main__": register()
Note, this is only a proof of concept. Other things to consider when moving from properties area elsewhere is
context.space.pin_id for when the panel is pinned. Have added another monkey patch to set pin in 3d view to none.