OSArch Community

Creating a 'quick favorite' for operators that are typically invoked through specific events

  1. T

    Just parking this here, as I use it quite often...

    This script creates a temporary user interface panel in Blender with a button that triggers a specified operator along with predefined properties. This setup allows users to easily access and add operators that are typically invoked through specific events to the Quick Favorites for more convenient usage.

    the key part to change is..

    
            layout.operator(
    
                "bim.create_drawing", 
    
                text="Create Drawing: Open Viewer"
    
            ).open_viewer = True
    
    
    import bpy
    
    class TEMP_PT_QuickFavoritePanel(bpy.types.Panel):
    
        """Temporary UI Panel to Add to Quick Favorites"""
    
        bl_label = "Quick Favorite Setup"
    
        bl_idname = "TEMP_PT_quick_favorite_panel"
    
        bl_space_type = 'VIEW_3D'
    
        bl_region_type = 'UI'
    
        bl_category = 'Tool'
    
        def draw(self, context):
    
            layout = self.layout
    
            # Add button for the operator with open_viewer=True
    
            layout.operator(
    
                "bim.create_drawing", 
    
                text="Create Drawing: Open Viewer'"
    
            ).open_viewer = True
    
    def register():
    
        bpy.utils.register_class(TEMP_PT_QuickFavoritePanel)
    
    def unregister():
    
        bpy.utils.unregister_class(TEMP_PT_QuickFavoritePanel)
    
    if __name__ == "__main__":
    
        register()
    

Login or Register to reply.