|
| 1 | + |
| 2 | +# ##### BEGIN GPL LICENSE BLOCK ##### |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or modify it |
| 5 | +# under the terms of the GNU General Public License as published by the Free |
| 6 | +# Software Foundation; either version 2 of the License, or (at your option) |
| 7 | +# any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | +# more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License along with |
| 15 | +# this program; if not, write to the Free Software Foundation, Inc., |
| 16 | +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | +# |
| 18 | +# ##### END GPL LICENSE BLOCK ##### |
| 19 | + |
| 20 | +# ##### BEGIN INFO BLOCK ##### |
| 21 | +# |
| 22 | +# Author: Trentin Frederick (a.k.a, proxe) |
| 23 | +# Contact: trentin.shaun.frederick@gmail.com |
| 24 | +# Version: 1.6.1 |
| 25 | +# |
| 26 | +# ##### END INFO BLOCK ##### |
| 27 | + |
| 28 | +# blender info |
| 29 | +bl_info = { |
| 30 | + 'name': 'Name Panel', |
| 31 | + 'author': 'Trentin Frederick (proxe)', |
| 32 | + 'version': (1, 6, 1), |
| 33 | + 'blender': (2, 67, 0), |
| 34 | + 'location': '3D View → Tool or Property Shelf → Name', |
| 35 | + 'description': 'In panel datablock name stack with batch name tools.', |
| 36 | + 'wiki_url': 'https://cgcookiemarkets.com/all-products/name-panel/?view=docs', |
| 37 | + 'tracker_url': 'https://github.com/trentinfrederick/name-panel/issues', |
| 38 | + 'category': '3D View' |
| 39 | +} |
| 40 | + |
| 41 | +# imports |
| 42 | +import bpy |
| 43 | +from bpy.types import AddonPreferences |
| 44 | +from bpy.props import * |
| 45 | +from .scripts import settings as PropertyGroup |
| 46 | +from .scripts.interface import button, icon, menu, name, properties |
| 47 | +from .scripts.operator import auto, batch, copy, icon, settings, text |
| 48 | + |
| 49 | +# addon |
| 50 | +addon = bpy.context.user_preferences.addons.get(__name__) |
| 51 | + |
| 52 | +# preferences |
| 53 | +class preferences(AddonPreferences): |
| 54 | + ''' |
| 55 | + Add-on user preferences. |
| 56 | + ''' |
| 57 | + bl_idname = __name__ |
| 58 | + |
| 59 | + # popups |
| 60 | + popups = BoolProperty( |
| 61 | + name = 'Pop-ups', |
| 62 | + description = 'Enable settings pop-up for modifiers and constraints. (Experimental!)', |
| 63 | + default = False |
| 64 | + ) |
| 65 | + |
| 66 | + # large popups |
| 67 | + largePopups = BoolProperty( |
| 68 | + name = 'Large Pop-ups', |
| 69 | + description = 'Increase the size of pop-ups.', |
| 70 | + default = False |
| 71 | + ) |
| 72 | + |
| 73 | + # location |
| 74 | + location = EnumProperty( |
| 75 | + name = 'Panel Location', |
| 76 | + description = 'The 3D view shelf to use (Save user settings and restart Blender.)', |
| 77 | + items = [ |
| 78 | + ('TOOLS', 'Tool Shelf', 'Places the Name panel in the tool shelf under the tab labeled \'Name\''), |
| 79 | + ('UI', 'Property Shelf', 'Places the Name panel in the property shelf.') |
| 80 | + ], |
| 81 | + default = 'TOOLS' |
| 82 | + ) |
| 83 | + |
| 84 | + # draw |
| 85 | + def draw(self, context): |
| 86 | + |
| 87 | + # layout |
| 88 | + layout = self.layout |
| 89 | + |
| 90 | + # row |
| 91 | + row = layout.row() |
| 92 | + |
| 93 | + # pop ups |
| 94 | + row.prop(self, 'popups') |
| 95 | + |
| 96 | + # pop ups |
| 97 | + row.prop(self, 'largePopups') |
| 98 | + |
| 99 | + # label |
| 100 | + layout.label(text='Location:') |
| 101 | + |
| 102 | + # row |
| 103 | + row = layout.row() |
| 104 | + row.prop(self, 'location', expand=True) |
| 105 | + |
| 106 | + # label |
| 107 | + layout.label(text='Links:') |
| 108 | + |
| 109 | + # split |
| 110 | + split = layout.split(align=True) |
| 111 | + split.scale_y = 2 |
| 112 | + |
| 113 | + # blender market |
| 114 | + prop = split.operator('wm.url_open', text='Blender Market') |
| 115 | + prop.url = 'https://cgcookiemarkets.com/all-products/name-panel/' |
| 116 | + |
| 117 | + # gumroad |
| 118 | + prop = split.operator('wm.url_open', text='Gumroad') |
| 119 | + prop.url = 'https://gumroad.com/l/UyXd' |
| 120 | + |
| 121 | + # blender artists |
| 122 | + prop = split.operator('wm.url_open', text='Blender Artists') |
| 123 | + prop.url = 'http://blenderartists.org/forum/showthread.php?272086' |
| 124 | + |
| 125 | + # github |
| 126 | + prop = split.operator('wm.url_open', text='Github') |
| 127 | + prop.url = 'https://github.com/trentinfrederick/name-panel' |
| 128 | + |
| 129 | +# register |
| 130 | +def register(): |
| 131 | + ''' |
| 132 | + Register. |
| 133 | + ''' |
| 134 | + |
| 135 | + # register module |
| 136 | + bpy.utils.register_module(__name__) |
| 137 | + |
| 138 | + # batch auto name settings |
| 139 | + bpy.types.Scene.BatchAutoName = PointerProperty( |
| 140 | + type = PropertyGroup.batch.auto.name, |
| 141 | + name = 'Batch Auto Name Settings', |
| 142 | + description = 'Storage location for the batch auto name operator settings.' |
| 143 | + ) |
| 144 | + |
| 145 | + # batch auto name object names |
| 146 | + bpy.types.Scene.BatchAutoName_ObjectNames = PointerProperty( |
| 147 | + type = PropertyGroup.batch.auto.objects, |
| 148 | + name = 'Batch Auto Name Object Names', |
| 149 | + description = 'Storage location for the object names used during the auto name operation.' |
| 150 | + ) |
| 151 | + |
| 152 | + # batch auto name constraint names |
| 153 | + bpy.types.Scene.BatchAutoName_ConstraintNames = PointerProperty( |
| 154 | + type = PropertyGroup.batch.auto.constraints, |
| 155 | + name = 'Batch Auto Name Constraint Names', |
| 156 | + description = 'Storage location for the constraint names used during the auto name operation.' |
| 157 | + ) |
| 158 | + |
| 159 | + # batch auto name modifier names |
| 160 | + bpy.types.Scene.BatchAutoName_ModifierNames = PointerProperty( |
| 161 | + type = PropertyGroup.batch.auto.modifiers, |
| 162 | + name = 'Batch Auto Name Modifier Names', |
| 163 | + description = 'Storage location for the modifier names used during the auto name operation.' |
| 164 | + ) |
| 165 | + |
| 166 | + # batch auto name object data names |
| 167 | + bpy.types.Scene.BatchAutoName_ObjectDataNames = PointerProperty( |
| 168 | + type = PropertyGroup.batch.auto.objectData, |
| 169 | + name = 'Batch Auto Name Object Data Names', |
| 170 | + description = 'Storage location for the object data names used during the auto name operation.' |
| 171 | + ) |
| 172 | + |
| 173 | + # batch name settings |
| 174 | + bpy.types.Scene.BatchName = PointerProperty( |
| 175 | + type = PropertyGroup.batch.name, |
| 176 | + name = 'Batch Name Settings', |
| 177 | + description = 'Storage location for the batch name operator settings.' |
| 178 | + ) |
| 179 | + |
| 180 | + # batch copy settings |
| 181 | + bpy.types.Scene.BatchCopyName = PointerProperty( |
| 182 | + type = PropertyGroup.batch.copy, |
| 183 | + name = 'Batch Name Copy Settings', |
| 184 | + description = 'Storage location for the batch copy name operator settings.' |
| 185 | + ) |
| 186 | + |
| 187 | + # name panel settings |
| 188 | + bpy.types.Scene.NamePanel = PointerProperty( |
| 189 | + type = PropertyGroup.name, |
| 190 | + name = 'Name Panel Settings', |
| 191 | + description = 'Storage location for the name panel settings.' |
| 192 | + ) |
| 193 | + |
| 194 | + # properties panel settings |
| 195 | + bpy.types.Scene.PropertiesPanel = PointerProperty( |
| 196 | + type = PropertyGroup.properties, |
| 197 | + name = 'Properties Panel Settings', |
| 198 | + description = 'Storage location for the properties panel settings.' |
| 199 | + ) |
| 200 | + |
| 201 | + # append |
| 202 | + bpy.types.OUTLINER_HT_header.append(button.batchName) |
| 203 | + |
| 204 | + # shelf position |
| 205 | + # addon |
| 206 | + if addon: |
| 207 | + try: |
| 208 | + if addon.preferences['location'] == 0: |
| 209 | + bpy.utils.unregister_class(name.UIName) |
| 210 | + bpy.utils.unregister_class(properties.UIProperties) |
| 211 | + else: |
| 212 | + bpy.utils.unregister_class(name.toolsName) |
| 213 | + bpy.utils.unregister_class(properties.toolsProperties) |
| 214 | + except: |
| 215 | + bpy.utils.unregister_class(name.UIName) |
| 216 | + bpy.utils.unregister_class(properties.UIProperties) |
| 217 | + else: |
| 218 | + bpy.utils.unregister_class(name.UIName) |
| 219 | + bpy.utils.unregister_class(properties.UIProperties) |
| 220 | + |
| 221 | +# unregister |
| 222 | +def unregister(): |
| 223 | + ''' |
| 224 | + Unregister. |
| 225 | + ''' |
| 226 | + |
| 227 | + # unregister module |
| 228 | + bpy.utils.unregister_module(__name__) |
| 229 | + |
| 230 | + # delete pointer properties |
| 231 | + del bpy.types.Scene.BatchAutoName |
| 232 | + del bpy.types.Scene.BatchAutoName_ObjectNames |
| 233 | + del bpy.types.Scene.BatchAutoName_ConstraintNames |
| 234 | + del bpy.types.Scene.BatchAutoName_ModifierNames |
| 235 | + del bpy.types.Scene.BatchAutoName_ObjectDataNames |
| 236 | + del bpy.types.Scene.BatchName |
| 237 | + del bpy.types.Scene.BatchCopyName |
| 238 | + del bpy.types.Scene.NamePanel |
| 239 | + |
| 240 | + # remove batch name button |
| 241 | + bpy.types.OUTLINER_HT_header.remove(button.batchName) |
| 242 | + |
| 243 | +if __name__ == '__main__': |
| 244 | + register() |
0 commit comments