0
$\begingroup$

So I created my first blender python script (yay), and the script works pretty well! Sure learning python by using it against grease pencil is probably a madmans desire to go insane, but I've already crossed that bridge.

The issue I am having is that when I go in and add the script as an add-on, the panel and two associated buttons do not appear. If I am in the scripting workspace and click play, it works normally.

I'm sure I'm missing something obvious but I was wondering if someone could guide me in the right direction.

I stripped out everything I think is not relevant, with the below barebones setup, I am able to simulate the issue. In script editor, pressing play creates the MISC section in the N panel (forgot the actual name but the thing that opens up when you press N), but importing it as an add-on does nothing.

#Import Necassary Modules
import bpy
#stuff goes her

###### GENERIC INTRO

bl_info = {
    'name': 'Creating a Perspective Grid for Grease Pencil',
    'category': 'All'
}


#########Variables
#stuff goes here




###############PANEL FOR UI###############

class PerspectiveGridPanel(bpy.types.Panel):
    bl_idname = "PerspectiveGridPanel.panel1"
    bl_label = "Perspective Grid Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    
    ###Draw the VP Button
    def draw(self, context):
        self.layout.operator("perspectivegrid.gp", icon='MESH_CUBE', text="Create Greapse Pencil Object")
        self.layout.operator("perspectivegrid.vp", icon='MESH_CUBE', text="Create VP")

##########################################




############### THE BUTTON THAT DOES STUFF###############    

class GPOBJECT_OT_vp(bpy.types.Operator):
    bl_idname = "perspectivegrid.gp"
    bl_label ="Perspective Grid Vanishing Point Genration"
    def execute(self, context):
        
        #######Grease Pencil Object Creation
        #stuff goes here
        return {'FINISHED'}

############### THE BUTTON THAT DOES STUFF###############    

class PERSPECTIVEGRID_OT_vp(bpy.types.Operator):
    bl_idname = "perspectivegrid.vp"
    bl_label ="Perspective Grid Vanishing Point Genration"
     
    def execute(self, context):
        #stuff goes her    
        return {'FINISHED'}

        ###########################################

#####################REGISTER / UNREGISTER######################        

def register():
    bpy.utils.register_class(PerspectiveGridPanel)
    bpy.utils.register_class(GPOBJECT_OT_vp)
    bpy.utils.register_class(PERSPECTIVEGRID_OT_vp)

def unregister():
    bpy.utils.unregister_class(PerspectiveGridPanel)
    bpy.utils.register_class(GPOBJECT_OT_vp)
    bpy.utils.unregister_class(PERSPECTIVEGRID_OT_vp)

if __name__ == '__main__':
    register()
$\endgroup$

2 Answers 2

0
$\begingroup$

Your panel class needs bl_category so that Blender will know which tab to add it to in the side panel. I tend to put mine in their own tab and use

    bl_category = "TLA"

but some people prefer to add their panesl to the "Tool" tab.

$\endgroup$
1
  • $\begingroup$ Hi, so I added a bl_category, and can confirm that rather than creating a MISC tab it now creates a tab with TLA or whatever I type in there when I press Play from scripting, but it still does not load when I go to preferences and install it as an add-on. $\endgroup$
    – NC_Sketchy
    Jul 5, 2022 at 19:14
0
$\begingroup$

Thanks to the kind folk over at blenderartists.org, I was able to get a resolution, there are multiple fields in bl_info that need to be filled out. The example provided for me was

bl_info = {
    'name': 'TimeTracker',
    'category': 'All',
    'author': 'Joseph Hansen',
    'version': (1, 0, 0),
    'blender': (3, 0, 0),
    'location': '',
    'description': 'Keep track of your time working in Blender'
}

https://blenderartists.org/t/unable-to-get-self-made-python-script-to-work-as-add-on-works-fine-in-scripting-workspace/1389576/2

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .