[Bf-extensions-cvs] [8f8e7125] master: addons-contrib: objects.link/unlink syntax update

NBurn noreply at git.blender.org
Wed Jan 30 03:59:27 CET 2019


Commit: 8f8e712558fadf4fc68ef99681d9d4b1ea9bd9b6
Author: NBurn
Date:   Tue Jan 29 21:58:30 2019 -0500
Branches: master
https://developer.blender.org/rBAC8f8e712558fadf4fc68ef99681d9d4b1ea9bd9b6

addons-contrib: objects.link/unlink syntax update

Change objects.link and objects.unlink from scene to collection

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

M	add_dimension.py
M	add_mesh_clusters/__init__.py
M	add_mesh_space_tree/__init__.py
M	camera_overscan.py
M	curve_tools/Surfaces.py
M	curve_tools/auto_loft.py
M	io_atomblend_utilities/io_atomblend_utilities.py
M	io_directx_bel/bel/mesh.py
M	io_directx_bel/bel/ob.py
M	io_directx_bel/import_x.py
M	io_import_LRO_Lola_MGS_Mola_img.py
M	io_import_voodoo_camera.py
M	io_mesh_gwyddion/import_gwyddion.py
M	io_mesh_xyz/import_xyz.py
M	io_points_pcd/pcd_utils.py
M	io_scene_cod/import_xmodel.py
M	io_scene_fpx/fpx_import.py
M	io_scene_map/export_map.py
M	io_scene_open_street_map.py
M	object_creaprim.py
M	oscurart_futurism.py
M	oscurart_mesh_cache_tools.py
M	oscurart_mesh_thread.py
M	render_cube_map.py
M	space_view3d_add_surround_cameras.py
M	space_view3d_enhanced_3d_cursor.py

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

diff --git a/add_dimension.py b/add_dimension.py
index c60c3cda..bdcd665d 100644
--- a/add_dimension.py
+++ b/add_dimension.py
@@ -52,7 +52,7 @@ def addText(string = '', loc = ((0, 0, 0)), textsize = 1, align = 'CENTER', offs
         fnt = bpy.data.fonts.load(font)
     tcu.font = fnt
     text.location = loc
-    bpy.context.scene.objects.link(text)
+    bpy.context.collection.objects.link(text)
 
     return text
 
@@ -1514,7 +1514,6 @@ def createCurve(vertArray, self, align_matrix):
     name = self.Dimension_Type         # Type as name
 
     # create curve
-    scene = bpy.context.scene
     newCurve = bpy.data.curves.new(name, type = 'CURVE') # curvedatablock
     newSpline = newCurve.splines.new('BEZIER') # spline
 
@@ -1528,7 +1527,7 @@ def createCurve(vertArray, self, align_matrix):
 
     # create object with newCurve
     DimensionCurve = bpy.data.objects.new(name, newCurve) # object
-    scene.objects.link(DimensionCurve) # place in active scene
+    bpy.context.collection.objects.link(DimensionCurve) # place in active scene
     DimensionCurve.Dimension = True
     DimensionCurve.matrix_world = align_matrix # apply matrix
     self.Dimension_Name = DimensionCurve.name
diff --git a/add_mesh_clusters/__init__.py b/add_mesh_clusters/__init__.py
index ef2a29a0..f034ce49 100644
--- a/add_mesh_clusters/__init__.py
+++ b/add_mesh_clusters/__init__.py
@@ -344,7 +344,7 @@ def DEF_atom_draw_atoms(prop_element,
     atom_mesh.from_pydata(atom_vertices, [], [])
     atom_mesh.update()
     new_atom_mesh = bpy.data.objects.new(name, atom_mesh)
-    bpy.context.scene.objects.link(new_atom_mesh)
+    bpy.context.collection.objects.link(new_atom_mesh)
 
     bpy.ops.surface.primitive_nurbs_surface_sphere_add(
                             view_align=False, enter_editmode=False,
diff --git a/add_mesh_space_tree/__init__.py b/add_mesh_space_tree/__init__.py
index 6938100b..9fc96327 100644
--- a/add_mesh_space_tree/__init__.py
+++ b/add_mesh_space_tree/__init__.py
@@ -320,7 +320,7 @@ def createObjects(tree, parent=None, objectname=None, probability=0.5, size=0.5,
                 obj.rotation_euler = rot[:]
                 obj.scale = [scale, scale, scale]
                 obj.parent = parent
-                bpy.context.scene.objects.link(obj)
+                bpy.context.collection.objects.link(obj)
                 # this is not the best choice of distribution because we might
                 # get negative values especially if sigma is large
                 t += gauss(1.0 / probability, 0.1)
@@ -565,7 +565,7 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
 
     # create the tree object an make it the only selected and active object in the scene
     obj_new = bpy.data.objects.new(mesh.name, mesh)
-    base = bpy.context.scene.objects.link(obj_new)
+    base = bpy.context.collection.objects.link(obj_new)
     for ob in bpy.context.scene.objects:
         ob.select_set(False)
     base.select_set(True)
@@ -611,7 +611,7 @@ def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5,
                     bleaf, connectoffset
                 )
         obj_leaves = bpy.data.objects.new(mesh.name, mesh)
-        base = bpy.context.scene.objects.link(obj_leaves)
+        base = bpy.context.collection.objects.link(obj_leaves)
         obj_leaves.parent = obj_new
         bpy.context.view_layer.objects.active = obj_leaves
         bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
@@ -975,7 +975,7 @@ class SCATree(bpy.types.Operator):
         if self.showMarkers:
             mesh = createMarkers(sca, self.markerScale)
             obj_markers = bpy.data.objects.new(mesh.name, mesh)
-            base = bpy.context.scene.objects.link(obj_markers)
+            base = bpy.context.collection.objects.link(obj_markers)
         timings.add('showmarkers')
 
         sca.iterate2(newendpointsper1000=self.newEndPointsPer1000, maxtime=self.maxTime)
diff --git a/camera_overscan.py b/camera_overscan.py
index ab4df77e..3be7e7b7 100644
--- a/camera_overscan.py
+++ b/camera_overscan.py
@@ -60,7 +60,7 @@ class CODuplicateCamera(Operator):
                 cam_obj = active_cam.copy()
                 cam_obj.data = active_cam.data.copy()
                 cam_obj.name = "Camera_Overscan"
-                context.scene.objects.link(cam_obj)
+                context.collection.objects.link(cam_obj)
         except:
             self.report({'WARNING'}, "Setting up a new Overscan Camera has failed")
             return {'CANCELLED'}
diff --git a/curve_tools/Surfaces.py b/curve_tools/Surfaces.py
index cfbf59c4..f2a1399d 100644
--- a/curve_tools/Surfaces.py
+++ b/curve_tools/Surfaces.py
@@ -119,7 +119,7 @@ class LoftedSurface:
 
         meshObject = bpy.data.objects.new(self.name, mesh)
 
-        bpy.context.scene.objects.link(meshObject)
+        bpy.context.collection.objects.link(meshObject)
 
 
 
@@ -267,7 +267,7 @@ class SweptSurface:
 
         meshObject = bpy.data.objects.new(self.name, mesh)
 
-        bpy.context.scene.objects.link(meshObject)
+        bpy.context.collection.objects.link(meshObject)
 
 
 
@@ -456,4 +456,4 @@ class BirailedSurface:
 
         meshObject = bpy.data.objects.new(self.name, mesh)
 
-        bpy.context.scene.objects.link(meshObject)
+        bpy.context.collection.objects.link(meshObject)
diff --git a/curve_tools/auto_loft.py b/curve_tools/auto_loft.py
index 70ecc4c8..a8bab35c 100644
--- a/curve_tools/auto_loft.py
+++ b/curve_tools/auto_loft.py
@@ -19,7 +19,6 @@ class OperatorAutoLoftCurves(Operator):
 
     def execute(self, context):
         #print("### TODO: OperatorLoftCurves.execute()")
-        scene = context.scene
         mesh = bpy.data.meshes.new("LoftMesh")
 
         curve0 = context.selected_objects[0]
@@ -31,7 +30,7 @@ class OperatorAutoLoftCurves(Operator):
 
         loftobj = bpy.data.objects.new(self.name, mesh)
 
-        scene.objects.link(loftobj)
+        context.collection.objects.link(loftobj)
         loftobj["autoloft"] = True
         if loftobj.get('_RNA_UI') is None:
             loftobj['_RNA_UI'] = {}
diff --git a/io_atomblend_utilities/io_atomblend_utilities.py b/io_atomblend_utilities/io_atomblend_utilities.py
index 0d9fd122..3b50f26a 100644
--- a/io_atomblend_utilities/io_atomblend_utilities.py
+++ b/io_atomblend_utilities/io_atomblend_utilities.py
@@ -656,7 +656,7 @@ def draw_obj_special(atom_shape, atom):
         new_mesh.from_pydata([Vector((0.0,0.0,0.0))], [], [])
         new_mesh.update()
         new_atom = bpy.data.objects.new(atom.name + "_sep", new_mesh)
-        bpy.context.scene.objects.link(new_atom)
+        bpy.context.collection.objects.link(new_atom)
         new_atom.location = atom.location
         material_new = bpy.data.materials.new(atom.active_material.name + "_sep")
         material_new.name = atom.name + "_halo"
@@ -698,7 +698,7 @@ def draw_obj_special(atom_shape, atom):
         lamp = bpy.data.objects.new("F2+_lamp", lamp_data)
         lamp.location = Vector((0.0, 0.0, 0.0))
         lamp.layers = current_layers
-        bpy.context.scene.objects.link(lamp)
+        bpy.context.collection.objects.link(lamp)
         lamp.parent = cube
         # The new 'atom' is the F2+ defect
         new_atom = cube
@@ -755,7 +755,7 @@ def draw_obj_special(atom_shape, atom):
         lamp = bpy.data.objects.new("F+_lamp", lamp_data)
         lamp.location = Vector((0.0, 0.0, 0.0))
         lamp.layers = current_layers
-        bpy.context.scene.objects.link(lamp)
+        bpy.context.collection.objects.link(lamp)
         lamp.parent = cube
         # The new 'atom' is the F+ defect complex + lamp
         new_atom = cube
@@ -823,7 +823,7 @@ def draw_obj_special(atom_shape, atom):
         lamp1 = bpy.data.objects.new("F0_lamp", lamp1_data)
         lamp1.location = Vector((scale[0]*1.5, 0.0, 0.0))
         lamp1.layers = current_layers
-        bpy.context.scene.objects.link(lamp1)
+        bpy.context.collection.objects.link(lamp1)
         lamp1.parent = cube
         lamp2_data = bpy.data.lamps.new(name="F0_lamp2", type="POINT")
         lamp2_data.distance = atom.scale[0] * 2.0
@@ -833,7 +833,7 @@ def draw_obj_special(atom_shape, atom):
         lamp2 = bpy.data.objects.new("F0_lamp", lamp2_data)
         lamp2.location = Vector((-scale[0]*1.5, 0.0, 0.0))
         lamp2.layers = current_layers
-        bpy.context.scene.objects.link(lamp2)
+        bpy.context.collection.objects.link(lamp2)
         lamp2.parent = cube
         # The new 'atom' is the F0 defect complex + lamps
         new_atom = cube
diff --git a/io_directx_bel/bel/mesh.py b/io_directx_bel/bel/mesh.py
index af290326..1363f04a 100644
--- a/io_directx_bel/bel/mesh.py
+++ b/io_directx_bel/bel/mesh.py
@@ -144,7 +144,7 @@ def write(obname,name,
 
     # scene link check
     if obj.name not in bpy.context.scene.objects.keys() :
-        bpy.context.scene.objects.link(obj)
+        bpy.context.collection.objects.link(obj)
 
     return obj
 
diff --git a/io_directx_bel/bel/ob.py b/io_directx_bel/bel/ob.py
index b9fec3ba..2ac50b5d 100644
--- a/io_directx_bel/bel/ob.py
+++ b/io_directx_bel/bel/ob.py
@@ -12,14 +12,14 @@ def new(name,datatype,naming_method):
             ob = bpy.data.objects.new(name,datatype)
             ob.name = name
         elif naming_method == 3 :
-            bpy.context.scene.objects.unlink(ob)
+            bpy.context.collection.objects.unlink(ob)
             ob.user_clear()
             bpy.data.objects.remove(ob)
             ob = bpy.data.objects.new(name,datatype)
     else :
         ob = bpy.data.objects.new(name,datatype)
     if ob.name not in bpy.context.scene.objects.keys() :
-        bpy.context.scene.objects.link(ob)
+        bpy.context.collection.objects.link(ob)
     return ob
 
 ## returns an object or a list of objects
diff --git a/io_directx_bel/import_x.py b/io_directx_bel/import_x.py
index 7c7bb641..250e36ec 100644
--- a/io_directx_bel/import_x.py
+++ b/io_directx_bel/import_x.py
@@ -591,7 +591,7 @@ BINARY FORMAT
             armname = armdata
             armdata = bpy.data.armatures.new(name=armname)
             arm = bpy.data.objects.new(armname,armdata)
-            bpy.context.scene.objects.link(arm)
+            bpy.co

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list