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()