[Bf-extensions-cvs] [5d5098a] master: Btrace: Major cleanup, reorganization

lijenstina noreply at git.blender.org
Wed Apr 12 00:58:37 CEST 2017


Commit: 5d5098af42dbaa631f6a90de5a327523f92bdc45
Author: lijenstina
Date:   Wed Apr 12 00:57:41 2017 +0200
Branches: master
https://developer.blender.org/rBA5d5098af42dbaa631f6a90de5a327523f92bdc45

Btrace: Major cleanup, reorganization

Bumped version to 1.2.1
Remove star imports
Split the bTrace file into two
Move the Panel and props code into the new file
Pep8 cleanup
Change the complicated switcher UI code Bools
replace them with one EnumProperty
This makes the second PropertyGroup not needed
Make optional layout configuration in the
preferences
Fix the crashes with the Drawing operator
Fix several crashes with wrong contexts
Some small UI fixes
More graceful error handling

===================================================================

M	btrace/__init__.py
M	btrace/bTrace.py
A	btrace/bTrace_props.py

===================================================================

diff --git a/btrace/__init__.py b/btrace/__init__.py
index 40ff4df..c1f6251 100644
--- a/btrace/__init__.py
+++ b/btrace/__init__.py
@@ -1,43 +1,96 @@
-#BEGIN GPL LICENSE BLOCK
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
 
-#This program is free software; you can redistribute it and/or
-#modify it under the terms of the GNU General Public License
-#as published by the Free Software Foundation; either version 2
-#of the License, or (at your option) any later version.
-
-#This program is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
-#GNU General Public License for more details.
-
-#You should have received a copy of the GNU General Public License
-#along with this program; if not, write to the Free Software Foundation,
-#Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#END GPL LICENCE BLOCK
 
 bl_info = {
     "name": "Btrace",
     "author": "liero, crazycourier, Atom, Meta-Androcto, MacKracken",
-    "version": (1, 1, ),
-    "blender": (2, 68, 0),
+    "version": (1, 2, 1),
+    "blender": (2, 78, 0),
     "location": "View3D > Tools",
     "description": "Tools for converting/animating objects/particles into curves",
     "warning": "",
     "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Curve/Btrace",
-    "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
     "category": "Add Curve"}
 
+if "bpy" in locals():
+    import importlib
+    importlib.reload(bTrace_props)
+    importlib.reload(bTrace)
+else:
+    from . import bTrace_props
+    from . import bTrace
 
 import bpy
-from .bTrace import *
-import selection_utils
-from bpy.props import FloatProperty, EnumProperty, IntProperty, BoolProperty, FloatVectorProperty
+from bpy.types import AddonPreferences
+from .bTrace_props import (
+        TracerProperties,
+        addTracerObjectPanel,
+        )
+from .bTrace import (
+        OBJECT_OT_convertcurve,
+        OBJECT_OT_objecttrace,
+        OBJECT_OT_objectconnect,
+        OBJECT_OT_writing,
+        OBJECT_OT_particletrace,
+        OBJECT_OT_traceallparticles,
+        OBJECT_OT_curvegrow,
+        OBJECT_OT_reset,
+        OBJECT_OT_fcnoise,
+        OBJECT_OT_meshfollow,
+        OBJECT_OT_materialChango,
+        OBJECT_OT_clearColorblender,
+        )
+from bpy.props import (
+        EnumProperty,
+        PointerProperty,
+        )
+
+
+# Add-on Preferences
+class btrace_preferences(AddonPreferences):
+    bl_idname = __name__
+
+    expand_enum = EnumProperty(
+            name="UI Options",
+            items=[
+                 ('list', "Drop down list",
+                  "Show all the items as dropdown list in the Tools Region"),
+                 ('col', "Enable Expanded UI Panel",
+                  "Show all the items expanded in the Tools Region in a column"),
+                 ('row', "Icons only in a row",
+                  "Show all the items as icons expanded in a row in the Tools Region")
+                  ],
+            description="",
+            default='list'
+            )
+
+    def draw(self, context):
+        layout = self.layout
+        layout.label("UI Options:")
 
-### Define Classes to register
-classes = [
+        row = layout.row(align=True)
+        row.prop(self, "expand_enum", text="UI Options", expand=True)
+
+
+# Define Classes to register
+classes = (
     TracerProperties,
-    TracerPropertiesMenu,
     addTracerObjectPanel,
     OBJECT_OT_convertcurve,
     OBJECT_OT_objecttrace,
@@ -50,18 +103,22 @@ classes = [
     OBJECT_OT_fcnoise,
     OBJECT_OT_meshfollow,
     OBJECT_OT_materialChango,
-    OBJECT_OT_clearColorblender
-    ]
+    OBJECT_OT_clearColorblender,
+    btrace_preferences,
+    )
+
 
 def register():
-    for c in classes:
-        bpy.utils.register_class(c)
-    bpy.types.WindowManager.curve_tracer = bpy.props.PointerProperty(type=TracerProperties)
-    bpy.types.WindowManager.btrace_menu = bpy.props.PointerProperty(type=TracerPropertiesMenu, update=deselect_others)
+    for cls in classes:
+        bpy.utils.register_class(cls)
+    bpy.types.WindowManager.curve_tracer = PointerProperty(type=TracerProperties)
+
 
 def unregister():
-    for c in classes:
-        bpy.utils.unregister_class(c)
+    for cls in classes:
+        bpy.utils.unregister_class(cls)
     del bpy.types.WindowManager.curve_tracer
+
+
 if __name__ == "__main__":
     register()
diff --git a/btrace/bTrace.py b/btrace/bTrace.py
index 9ac2cfc..82d93f9 100644
--- a/btrace/bTrace.py
+++ b/btrace/bTrace.py
@@ -1,750 +1,206 @@
-#BEGIN GPL LICENSE BLOCK
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# TO DO LIST #
+# Add more options to curve radius/modulation plus cyclic/connect curve option
 
-#This program is free software; you can redistribute it and/or
-#modify it under the terms of the GNU General Public License
-#as published by the Free Software Foundation; either version 2
-#of the License, or (at your option) any later version.
-
-#This program is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
-#GNU General Public License for more details.
+import bpy
+import selection_utils
+from bpy.types import Operator
+from random import (
+        choice as rand_choice,
+        random as rand_random,
+        randint as rand_randint,
+        uniform as rand_uniform,
+        )
 
-#You should have received a copy of the GNU General Public License
-#along with this program; if not, write to the Free Software Foundation,
-#Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#END GPL LICENCE BLOCK
+def error_handlers(self, op_name, error, reports="ERROR", func=False):
+    if self and reports:
+        self.report({'WARNING'}, reports + " (See Console for more info)")
 
-bl_info = {
-    "name": "Btrace",
-    "author": "liero, crazycourier, Atom, Meta-Androcto, MacKracken",
-    "version": (1, 1, ),
-    "blender": (2, 71, 0),
-    "location": "View3D > Toolshelf > Addons Tab",
-    "description": "Tools for converting/animating objects/particles into curves",
-    "warning": "Still under development, bug reports appreciated",
-    "wiki_url": "",
-    "tracker_url": "https://developer.blender.org/T29563",
-    "category": "Add Curve"}
+    is_func = "Function" if func else "Operator"
+    print("\n[Btrace]\n{}: {}\nError: {}\n".format(op_name, is_func, error))
 
 
-#### TO DO LIST ####
-### [   ]  Add more options to curve radius/modulation plus cyclic/connect curve option
+# Object Trace
+# creates a curve with a modulated radius connecting points of a mesh
 
-import bpy
-import selection_utils
-from bpy.props import FloatProperty, EnumProperty, IntProperty, BoolProperty, FloatVectorProperty
-
-
-def deselect_others(ob, context):
-    """For tool menu select, deselects others if one selected"""
-    selected = addTracerObjectPanel.selected
-    ob[selected] = False
-    keys = [key for key in ob.keys() if ob[key]]  # all the True keys
-    if len(keys) <= 0:
-        ob[selected] = True  # reselect
-        return None
-    for key in keys:
-        addTracerObjectPanel.selected = key
-        ob[key] = True
-
-
-# Class for properties panel
-class TracerPropertiesMenu(bpy.types.PropertyGroup):
-    """Toolbar show/hide booleans for tool options"""
-    tool_objectTrace = BoolProperty(name="Object Trace", default=False, description="Trace selected mesh object with a curve", update=deselect_others)
-    tool_objectsConnect = BoolProperty(name="Objects Connect", default=False, description="Connect objects with a curve controlled by hooks", update=deselect_others)
-    tool_particleTrace = BoolProperty(name="Particle Trace", default=False, description="Trace particle path with a  curve", update=deselect_others)
-    tool_meshFollow = BoolProperty(name="Mesh Follow", default=False, description="Follow selection items on animated mesh object", update=deselect_others)
-    tool_particleConnect = BoolProperty(name="Particle Connect", default=False, description="Connect particles with a curves and animated over particle lifetime", update=deselect_others)
-    tool_growCurve = BoolProperty(name="Grow Curve", default=False, description="Animate curve bevel over time by keyframing points radius", update=deselect_others)
-    tool_handwrite = BoolProperty(name="Handwriting", default=False, description="Create and Animate curve using the grease pencil", update=deselect_others)
-    tool_fcurve = BoolProperty(name="F-Curve Noise", default=False, description="Add 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list