[Bf-extensions-cvs] [a953af8c] master: btrace: initial update for 2.8

meta-androcto noreply at git.blender.org
Wed May 22 01:22:30 CEST 2019


Commit: a953af8c9e3ab7ee3fa2fec171a525f5f9b6cedd
Author: meta-androcto
Date:   Wed May 22 09:22:10 2019 +1000
Branches: master
https://developer.blender.org/rBAa953af8c9e3ab7ee3fa2fec171a525f5f9b6cedd

btrace: initial update for 2.8

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

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

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

diff --git a/btrace/__init__.py b/btrace/__init__.py
index fe0c4758..4e200a53 100644
--- a/btrace/__init__.py
+++ b/btrace/__init__.py
@@ -20,29 +20,30 @@
 bl_info = {
     "name": "Btrace",
     "author": "liero, crazycourier, Atom, Meta-Androcto, MacKracken",
-    "version": (1, 2, 1),
-    "blender": (2, 78, 0),
-    "location": "View3D > Tools",
+    "version": (1, 2, 2),
+    "blender": (2, 80, 0),
+    "location": "View3D",
     "description": "Tools for converting/animating objects/particles into curves",
-    "warning": "",
+    "warning": "Particle Tracers not working",
     "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Curve/Btrace",
     "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
+
+# if "bpy" in locals():
+#     import importlib
+#     importlib.reload(bTrace_props)
+#     importlib.reload(bTrace)
+# else:
+#     from . import bTrace_props
+#     from . import bTrace
+from . import bTrace_props
+from . import bTrace
+
 from bpy.types import AddonPreferences
-from .bTrace_props import (
-    TracerProperties,
-    addTracerObjectPanel,
-)
-from .bTrace import (
+from . bTrace_props import TracerProperties
+
+from . bTrace import (
     OBJECT_OT_convertcurve,
     OBJECT_OT_objecttrace,
     OBJECT_OT_objectconnect,
@@ -56,6 +57,8 @@ from .bTrace import (
     OBJECT_OT_materialChango,
     OBJECT_OT_clearColorblender,
 )
+
+from . bTrace_panel import addTracerObjectPanel
 from bpy.props import (
     EnumProperty,
     PointerProperty,
@@ -104,21 +107,21 @@ classes = (
     OBJECT_OT_meshfollow,
     OBJECT_OT_materialChango,
     OBJECT_OT_clearColorblender,
-    btrace_preferences,
+    btrace_preferences
     )
 
 
+
+# register, unregister = bpy.utils.register_classes_factory(classes)
 def register():
     for cls in classes:
         bpy.utils.register_class(cls)
     bpy.types.WindowManager.curve_tracer = PointerProperty(type=TracerProperties)
 
-
 def unregister():
     for cls in classes:
         bpy.utils.unregister_class(cls)
     del bpy.types.WindowManager.curve_tracer
 
-
-if __name__ == "__main__":
-    register()
+# if __name__ == "__main__":
+#     register()
diff --git a/btrace/bTrace.py b/btrace/bTrace.py
index 9897afcc..f4d64a0c 100644
--- a/btrace/bTrace.py
+++ b/btrace/bTrace.py
@@ -20,7 +20,7 @@
 # Add more options to curve radius/modulation plus cyclic/connect curve option
 
 import bpy
-import selection_utils
+# import selection_utils
 from bpy.types import Operator
 from random import (
         choice as rand_choice,
@@ -29,6 +29,63 @@ from random import (
         uniform as rand_uniform,
         )
 
+# Selection Module: Contributors: Mackraken, Andrew Hale (TrumanBlending)
+# Adapted from Mackraken's "Tools for Curves" addon
+
+
+selected = []
+
+
+class SelectionOrder(bpy.types.Operator):
+    """Store the object names in the order they are selected, """ \
+    """use RETURN key to confirm selection, ESCAPE key to cancel"""
+    bl_idname = "object.select_order"
+    bl_label = "Select with Order"
+    bl_options = {'UNDO'}
+
+    num_selected = 0
+
+    @classmethod
+    def poll(self, context):
+        return bpy.context.mode == 'OBJECT'
+
+    def update(self, context):
+        # Get the currently selected objects
+        sel = context.selected_objects
+        num = len(sel)
+
+        if num == 0:
+            # Reset the list
+            del selected[:]
+        elif num > self.num_selected:
+            # Get all the newly selected objects and add
+            new = [ob.name for ob in sel if ob.name not in selected]
+            selected.extend(new)
+        elif num < self.num_selected:
+            # Get the selected objects and remove from list
+            curnames = {ob.name for ob in sel}
+            selected[:] = [name for name in selected if name in curnames]
+
+        # Set the number of currently select objects
+        self.num_selected = len(selected)
+
+    def modal(self, context, event):
+        if event.type == 'RET':
+            # If return is pressed, finish the operator
+            return {'FINISHED'}
+        elif event.type == 'ESC':
+            # If escape is pressed, cancel the operator
+            return {'CANCELLED'}
+
+        # Update selection if we need to
+        self.update(context)
+        return {'PASS_THROUGH'}
+
+    def invoke(self, context, event):
+        self.update(context)
+
+        context.window_manager.modal_handler_add(self)
+        return {'RUNNING_MODAL'}
 
 def error_handlers(self, op_name, error, reports="ERROR", func=False):
     if self and reports:
@@ -115,9 +172,10 @@ class OBJECT_OT_objectconnect(Operator):
             if curve_handle == 'AUTOMATIC':  # hackish because of naming conflict in api
                 curve_handle = 'AUTO'
             # Check if Btrace group exists, if not create
-            bgroup = bpy.data.collections.keys()
-            if 'Btrace' not in bgroup:
-                bpy.ops.collections.create(name="Btrace")
+            bcollection = bpy.data.collections.keys()
+            if 'Btrace' not in bcollection:
+                mycol=bpy.data.collections.new(name="Btrace")
+                bpy.context.scene.collection.children.link(mycol)
             #  check if noise
             if Btrace.connect_noise:
                 bpy.ops.object.btfcnoise()
@@ -181,7 +239,9 @@ class OBJECT_OT_objectconnect(Operator):
             if Btrace.animate:   # Add Curve Grow it?
                 bpy.ops.curve.btgrow()
 
-            bpy.ops.object.collection_link(group="Btrace")  # add to Btrace group
+            bpy.data.collections["Btrace"].objects.link(curve) # add to Btrace collection
+            
+            # Check if we add grow curve
             if Btrace.animate:
                 bpy.ops.curve.btgrow()  # Add grow curve
 
@@ -213,10 +273,9 @@ def curvetracer(curvename, splinename):
     tracer.bevel_resolution = Btrace.curve_resolution
     tracer.bevel_depth = Btrace.curve_depth
     tracer.resolution_u = Btrace.curve_u
-
     return tracer, curve
 
-
+# Particle Trace
 class OBJECT_OT_particletrace(Operator):
     bl_idname = "particles.particletrace"
     bl_label = "Btrace: Particle Trace"
@@ -231,9 +290,10 @@ class OBJECT_OT_particletrace(Operator):
 
     def execute(self, context):
         try:
-            Btrace = context.window_manager.curve_tracer
+            Btrace = bpy.context.window_manager.curve_tracer
             particle_step = Btrace.particle_step    # step size in frames
             obj = bpy.context.object
+            obj = bpy.context.depsgraph.objects.get(ob.name, None)
             ps = obj.particle_systems.active
             curvelist = []
             curve_handle = Btrace.curve_handle
@@ -245,20 +305,24 @@ class OBJECT_OT_particletrace(Operator):
                 curve_handle = 'FREE'
 
             # Check if Btrace group exists, if not create
-            bgroup = bpy.data.collections.keys()
-            if 'Btrace' not in bgroup:
-                bpy.ops.collection.create(name="Btrace")
+            bcollection = bpy.data.collections.keys()
+            if 'Btrace' not in bcollection:
+                mycol=bpy.data.collections.new(name="Btrace")
+                bpy.context.scene.collection.children.link(mycol)
 
             if Btrace.curve_join:
                 tracer = curvetracer('Tracer', 'Splines')
+            
             for x in ps.particles:
                 if not Btrace.curve_join:
                     tracer = curvetracer('Tracer.000', 'Spline.000')
                 spline = tracer[0].splines.new('BEZIER')
+
                 # add point to spline based on step size
                 spline.bezier_points.add((x.lifetime - 1) // particle_step)
                 for t in list(range(int(x.lifetime))):
                     bpy.context.scene.frame_set(t + x.birth_time)
+                    
                     if not t % particle_step:
                         p = spline.bezier_points[t // particle_step]
                         p.co = x.location
@@ -266,12 +330,13 @@ class OBJECT_OT_particletrace(Operator):
                         p.handle_left_type = curve_handle
                 particlecurve = tracer[1]
                 curvelist.append(particlecurve)
+
             # add to group
             bpy.ops.object.select_all(action='DESELECT')
             for curveobject in curvelist:
                 curveobject.select_set(True)
                 bpy.context.view_layer.objects.active = curveobject
-                bpy.ops.object.collection_link(group="Btrace")
+                bpy.data.collections["Btrace"].objects.link(curveobject)
                 # Materials
                 trace_mats = addtracemat(curveobject.data)
                 if not trace_mats and check_materials is True:
@@ -310,6 +375,7 @@ class OBJECT_OT_traceallparticles(Operator):
     def execute(self, context):
         try:
             obj = context.object
+            eval_ob = bpy.context.depsgraph.objects.get(obj.name, None)
             ps = obj.particle_systems.active
             setting = ps.settings
 
@@ -336,7 +402,8 @@ class OBJECT_OT_traceallparticles(Operator):
             # Create new object with settings listed above
             curve = bpy.data.objects.new('Tracer', tracer)
             # Link newly created object to the scene
-            bpy.context.collection.objects.link(curve)
+            # bpy.context.view_layer.objects.link(curve)
+            bpy.context.scene.collection.objects.link(curve)
             # add a new Bezier point in the new curve
             spline = tracer.splines.new('BEZIER')
             spline.bezier_points.add(setting.count - 1)
@@ -666,11 +733,11 @@ class OBJECT_OT_meshfollow(Operator):
                         followed_item = meshobjs[objindex]
                         if drawmethod == 'VERTS':
                             # find Vert vector
-                            g_co = obj.matrix_local * followed_item.co
+                            g_co = obj.matrix_local @ followed_item.co
 
                         if drawmethod == 'FACES':
       

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list