1ebl_info = {
2    "name": "Pie Menu: Template",
3    "description": "Pie menu example",
4    "author": "Viktor Stepanov / pon",
5    "version": (0, 1, 1),
6    "blender": (4, 2, 0),
7    "location": "3D View",
8    "warning": "",
9    "doc_url": "",
10    "category": "Development",
11}
12import bpy
13from bpy.types import Menu
14
15
16
17
18def add_geo_nodes():#(subdiv_viewport_levels, subdiv_render_levels):
19    obj = bpy.context.active_object
20
21    if obj is None:
22        print("warning: no active object")
23        return
24
25    if obj.type != "MESH":
26        print("warning: the active object need to be a mesh")
27        return
28    
29    bpy.ops.object.modifier_add(type='NODES')
30    bpy.ops.node.new_geometry_node_group_assign()
31    
32   # bpy.ops.object.modifier_add(type="SUBSURF")
33#    bpy.context.object.modifiers["Subdivision"].levels = subdiv_viewport_levels
34#    bpy.context.object.modifiers["Subdivision"].render_levels = subdiv_render_levels
35
36
37class MESH_OT_add_subdiv_mod(bpy.types.Operator):
38    """Add a subdivision surf modifier to the active mesh"""
39
40    bl_idname = "mesh.add_geo_nodes"
41    bl_label = "Add Subdivision Surf Modifier to the Active Mesh Object"
42    bl_options = {"REGISTER", "UNDO"}
43
44    subdiv_viewport_lvl: bpy.props.IntProperty(
45        name="Subdiv Viewport",
46        default=1,
47        min=1,
48        max=3,
49        description="The Subdivision Levels applied in the Viewport",
50    )
51
52    subdiv_render_lvl: bpy.props.IntProperty(
53        name="Subdiv Render",
54        default=3,
55        min=3,
56        max=7,
57        description="The Subdivision Levels applied during the Viewport",
58    )
59
60    def execute(self, context):
61        add_geo_nodes()#(self.subdiv_viewport_lvl, self.subdiv_render_lvl) # I think this is where it runs the goe nodes script
62        return {"FINISHED"}
63    
64# -------------------------------------------------
65class SwitchGeometryEditor(bpy.types.Operator):
66    bl_idname = "node.switch_to_geometry_editor"
67    bl_label = "Switch to Geometry Editor"
68
69    def execute(self, context):
70        bpy.context.area.ui_type = "GeometryNodeTree"
71        return {"FINISHED"}
72   # -------------------------------------------------
73
74
75class VIEW3D_MT_PIE_template(Menu):
76    # label is displayed at the center of the pie menu.
77    bl_label = "Hot Pot Pie"
78
79    def draw(self, context):
80        layout = self.layout
81
82        pie = layout.menu_pie()
83        
84        column = pie.split().column()
85        column.operator("mesh.primitive_plane_add", text="Add Plane", icon="MESH_PLANE")
86        column.operator("mesh.primitive_cube_add", text="Add Cube", icon="MESH_CUBE")
87        
88        #column = pie.split().column()
89        column.operator("mesh.primitive_ico_sphere_add", text="Add Ico Shere", icon="MESH_ICOSPHERE")
90        column.operator("mesh.primitive_uv_sphere_add", text="Add UV Sphere", icon="MESH_UVSPHERE")
91        column.operator("object.gpencil_add", text="Add Grease Pencil", icon="GREASEPENCIL")
92        #column = pie.separator()
93        #column = pie.separator()
94        column = pie.separator()
95        column = pie.split().column()
96        #column.operator("mesh.add_subdiv_mod", text="Add Geo Nodes", icon="GEOMETRY_NODES")
97        #pie.operator("object.editmode_toggle", text="Eidt/Object", icon="OBJECT_DATAMODE")
98        pie.operator("mesh.add_geo_nodes", text="Add Geo Nodes", icon="GEOMETRY_NODES")
99        column.operator("object.shade_smooth", text="Shade Smooth", icon="MOD_SMOOTH")
100        #---------------------------------------------------------------------------------------
101        column = pie.separator()
102        #column = pie.separator()
103        column = pie.split().column()
104        column.operator("mesh.primitive_plane_add", text="Add Plane", icon="MESH_PLANE")
105        column.operator("mesh.primitive_cube_add", text="Add Cube", icon="MESH_CUBE")
106        
107        #column = pie.split().column()
108        column.operator("mesh.primitive_ico_sphere_add", text="Add Ico Shere", icon="MESH_ICOSPHERE")
109        column.operator("mesh.primitive_uv_sphere_add", text="Add UV Sphere", icon="MESH_UVSPHERE")
110        column.operator("object.gpencil_add", text="Add Grease Pencil", icon="GREASEPENCIL")
111        
112        
113#        row = layout.row(align=True)
114#        row.operator(
115#            "node.switch_to_geometry_editor", text="", icon="GEOMETRY_NODES"
116#        )
117        
118            
119        #column.operator("ui_type= 'CompositorNodeTree'", text= "Comp", icon="NODE_COMPOSITING")
120        
121       
122       
123        # bpy.context.area.ui_type = 'CompositorNodeTree'
124
125        
126
127# bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=(0.150648, -0.147638, -0.13872), scale=(1, 1, 1))
128# bpy.ops.mesh.primitive_ico_sphere_add(radius=1, enter_editmode=False, align='WORLD', location=(0.150648, -0.147638, -0.13872), scale=(1, 1, 1))
129# bpy.ops.object.gpencil_add(align='WORLD', location=(-0.39162, -3.99968, -1.56407), scale=(1, 1, 1), type='EMPTY')
130# bpy.ops.mesh.primitive_uv_sphere_add(radius=1, enter_editmode=False, align='WORLD', location=(-0.39162, -3.99968, -1.56407), scale=(1, 1, 1))
131
132
133global_addon_keymaps = []
134
135
136def register():
137    bpy.utils.register_class(MESH_OT_add_subdiv_mod)
138    bpy.utils.register_class(VIEW3D_MT_PIE_template)
139
140    window_manager = bpy.context.window_manager
141    if window_manager.keyconfigs.addon:
142        keymap = window_manager.keyconfigs.addon.keymaps.new(name="3D View", space_type="VIEW_3D")
143       # keymap = window_manager.keyconfigs.addon.keymaps.new(name="Node Editor", space_type="NODE_EDITOR")
144
145        keymap_item = keymap.keymap_items.new("wm.call_menu_pie", "A", "PRESS", ctrl=True, shift=True)
146        keymap_item.properties.name = "VIEW3D_MT_PIE_template"
147
148        # save the key map to deregister later
149        global_addon_keymaps.append((keymap, keymap_item))
150
151
152def unregister():
153    bpy.utils.unregister_class(VIEW3D_MT_PIE_template)
154    bpy.utils.unregister_class(MESH_OT_add_subdiv_mod)
155
156    window_manager = bpy.context.window_manager
157    if window_manager and window_manager.keyconfigs and window_manager.keyconfigs.addon:
158        for keymap, keymap_item in global_addon_keymaps:
159            keymap.keymap_items.remove(keymap_item)
160
161    global_addon_keymaps.clear()
162
163
164if __name__ == "__main__":
165    register()
166