Skip to content

Commit

Permalink
Update 0.0.4
Browse files Browse the repository at this point in the history
new things added and bug fixes
  • Loading branch information
jacobsamo committed May 26, 2022
1 parent 58a3a60 commit a55b72a
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 135 deletions.
211 changes: 162 additions & 49 deletions Sago Zip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@

bl_info = {
"name": "Sago",
"description": "Extra render settings STILL IN EARLY STAGES OF DEVOLMENT",
"description": "Extra render settings and quick acces tool",
"author": "Jacob Samorowksi",
"version": (0, 0, 3),
"version": (0, 0, 4),
"blender": (2, 83, 0),
"location": "3d View > Tool shelf",
"warning": "make sure that all your files are saved before clicking shutdown computer otherwise you will lose files i take no responsibility for the lose of files and make sure that the blend file is saved before rendering as it will not work",
"warning": "Make sure other files on computer are saved",
"doc_url": "https://github.com/Eirfire/Blender-addon/wiki",
"tracker_url": "https://github.com/Eirfire/Blender-addon/issues",
"support": "COMMUNITY",
"category": "Generic"
"category": "Generic",
}


#import blender python modules
from cProfile import label
from unicodedata import name
import bpy
import bmesh
from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty,)
Expand All @@ -46,14 +44,15 @@
from math import *

#import classes from files
from . hello_world import (
hello_world,
)
from . operators import(
MESH_OT_MONKEY_grid,
camera_settings,
NODE_OT_customgroup,
SAGO_OT_add_displace,
sago_mod_subsurf,
sago_mod_displace,
sago_mod_array,
sago_mod_wireframe,
toggle_face_orientation,
)

from . ui_panels import(
Expand All @@ -64,39 +63,15 @@
)

from . ui_menus import(
WM_MT_pie_menu,
SAGO_MT_pie_menu,

)



#------------------------------------------------------------------------------------------
#Custom Properties
#------------------------------------------------------------------------------------------
class sago_addon_properties(AddonPreferences):
bl_idname = __name__



def draw(self, context):
layout = self.layout
wm = context.window_manager
box = layout.box()
row = box.row()
col = row.column()

box.label(text='Test box')
box.label(text='in the addon there are many different operators and menus:\n')
box.label(text='locations of items:')
box.label(text='1. Pie menu- Hotkey = Mouse button 4')
box.label(text='2. side panel - 3D view > toolshelf > sago')

box.label(text='IMPORTANT!!! This addon is still in early devolment and there will be bugs so sorrybut please let me know if youand i try and fix them ASAP')

box.label(text='Thank Jacob')

col.operator("wm.url_open", text="Resport Issues").url = "https://github.com/Eirfire/Sago-Extra-Render-Addon/issues"


class SagoProperties(PropertyGroup):


Expand Down Expand Up @@ -132,25 +107,170 @@ class SagoProperties(PropertyGroup):
default=0.5,
min=0, soft_max=1,
)


#prefence that go in the addon aera in prefences for the addon
class sago_addon_properties(AddonPreferences):
bl_idname = __name__

tabs: EnumProperty(
name="Tabs",
items=[
("GENERAL", "General", ""),
("INFO", "Info", ""),
("KEYMAP", "Keymap", ""),
],
default="GENERAL",
)

#main drawing panel with the tabs
def draw(self, context):
layout = self.layout

column = layout.column(align=True)
row = column.row()
row.prop(self, "tabs", expand=True)

box = layout.box()

if self.tabs == "GENERAL":
self.draw_general(box)
elif self.tabs == "INFO":
self.draw_info(box)
elif self.tabs == "KEYMAP":
self.draw_keymap(box)

#what is shown if the tab is set to general
def draw_general(self, box):
layout = self.layout
wm = bpy.context.window_manager
box = layout.box()
row = box.row()
col = row.column()

box.label(text='version ' + str(bl_info["version"]))
box.label(text='Panel- 3D view > toolshelf > sago')
box.label(text='Pie menu - hotkey mouse button 4')
box.label(text='hotkeys can be change in the hotkeys tab')

#what is shown if the tab is set to info
def draw_info(self, box):
layout = self.layout
wm = bpy.context.window_manager
box = layout.box()
row = box.row()
col = row.column()

box.label(text='Test box')
box.label(text='in the addon there are many different operators and menus:\n')
box.label(text='locations of items:')
box.label(text='1. Pie menu- Hotkey = Mouse button 4')
box.label(text='2. side panel - 3D view > toolshelf > sago')

box.label(text='IMPORTANT!!! This addon is still in early devolment and there will be bugs so sorrybut please let me know if youand i try and fix them ASAP')

box.label(text='Thank Jacob')

box.operator("wm.url_open", text="Resport Issues").url = "https://github.com/Eirfire/Sago-Extra-Render-Addon/issues"

#what is shown if the tab is set to keymap
def draw_keymap(self, box):
layout = self.layout
wm = bpy.context.window_manager
box = layout.box()
row = box.row()
col = row.column()

col.label(text='Pie menu hot key:')
wm = bpy.context.window_manager
kc = wm.keyconfigs.user
km = kc.keymaps['3D View Generic']
kmi = get_hotkey_entry_item(km, 'wm.call_menu_pie', f'{str(pie_menu_name)}')
if kmi:
col.context_pointer_set('keymap', km)
rna_keymap_ui.draw_kmi([], kc, km, kmi, col, 0)
else:
col.label(text='No hotkey found', icon='ERROR')
col.operator('add_hotkey.sago', text='Add hotkey')








#add hotkey/ hotkeys to blender
addon_keymaps = []
pie_menu_name = SAGO_MT_pie_menu.bl_idname

#find the hotkey in blenders keymap
def get_hotkey_entry_item(km, kmi_name, kmi_value):

for i, km_item in enumerate(km.keymap_items):
if km.keymap_items.keys()[i] == kmi_name:
if km.keymap_items[i].properties.name == kmi_value:
return km_item
return None

#adds the hotkey to blenders keymap
def add_hotkey():

addon_prefs = bpy.context.preferences.addons[__name__].preferences

kc = bpy.context.window_manager.keyconfigs.addon
if kc:
km = kc.keymaps.new(name='3D View Generic', space_type='VIEW_3D', region_type='WINDOW')
kmi = km.keymap_items.new('wm.call_menu_pie', type='BUTTON4MOUSE', value='PRESS', ctrl=False, shift=False, alt=False)
kmi.properties.name = f'{str(pie_menu_name)}'
kmi.active = True
addon_keymaps.append((km, kmi))

#removes the hotkey from blenders keymap
def remove_hotkey():

for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)

addon_keymaps.clear()

#if get_hotkey_entry_item can't find a hotkey this will be called in the pannel
class USERPREF_OT_change_hotkey(Operator):
'''Add hotkey'''
bl_idname = "add_hotkey.sago"
bl_label = "Add Hotkey"
bl_options = {'REGISTER', 'INTERNAL'}

def execute(self, context):
add_hotkey()
return {'FINISHED'}






#add all classes to be registered
classes = (
#panels
VEIW3D_PT_Main_Panel,
VEIW3D_PT_ExtraRender,
NODE_PT_customPanel,
#menus
WM_MT_pie_menu,
SAGO_MT_pie_menu,
#properties
SagoProperties,
sago_addon_properties,
USERPREF_OT_change_hotkey,
#operators
MESH_OT_MONKEY_grid,
NODE_OT_customgroup,
camera_settings,
SAGO_OT_add_displace,
sago_mod_subsurf,
sago_mod_displace,
sago_mod_array,
sago_mod_wireframe,
toggle_face_orientation,
)

# Register
Expand All @@ -174,14 +294,8 @@ def register():
for cls in classes:
bpy.utils.register_class(cls)

#add a keymap for pie menu
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
km = kc.keymaps.new(name='3D View', space_type='VIEW_3D')
kmi = km.keymap_items.new("wm.call_menu_pie", type='BUTTON4MOUSE', value='PRESS')
kmi.properties.name = "WM_MT_pie_menu"
addon_keymaps.append((km,kmi))
#add hotkey/ hotkeys
add_hotkey()
#register custom properties
bpy.types.Scene.sago = PointerProperty(type=SagoProperties)

Expand All @@ -193,11 +307,10 @@ def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
#unregister keymaps
for km,kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
remove_hotkey()
#unregister properties
del bpy.types.Scene.sago

#makes the file an executable file and reduces errors in code
if __name__ == "__main__":
register()
35 changes: 35 additions & 0 deletions Sago Zip/changelogs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
welcome to the change logs for Sago

creidt to the poeple below for the use of their addons for refence for my own code:
Addon: Bagapie > by: Antoine Bagattini
Addon: ND-v1.27.0 > by: HugeMenace






V 0.0.4
Overall changes:
- Bug fixes
- General improvements
- made things look nicer with newer Formats

Operators:
new operators:
> face orientation- shows normals of a faces
> add modifiers - modifers: displace, subsurf, array, wireframe


Panels:
- made things look nicer
- added it so you can save images


Menus:
- made the pie menu look nicer and added more things to it like modifiers and new Operators


Addon preferences:
- made it look nicer and easier to use
- added support to change hotkey for the pie menu
23 changes: 0 additions & 23 deletions Sago Zip/hello_world.py

This file was deleted.

Loading

0 comments on commit a55b72a

Please sign in to comment.