Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-04-04 17:37:55 +0300
committerJacques Lucke <mail@jlucke.com>2019-04-04 17:37:55 +0300
commitdf3c1dde04442b148c547f09fac51a32589f83ea (patch)
tree9998ffae361f399fc253f28483d9fc5e86cc6728 /release
parent3c7a538c9b73ff7ab87ba508c5d44433d6c2877b (diff)
Fix T63256: Make Dupli Face was broken since there are collections
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/object.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 22da314aea5..f2124c094a7 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -594,6 +594,7 @@ class MakeDupliFace(Operator):
@staticmethod
def _main(context):
from mathutils import Vector
+ from collections import defaultdict
SCALE_FAC = 0.01
offset = 0.5 * SCALE_FAC
@@ -610,11 +611,10 @@ class MakeDupliFace(Operator):
return [(rot @ b) + trans for b in base_tri]
scene = context.scene
- linked = {}
+ linked = defaultdict(list)
for obj in context.selected_objects:
- data = obj.data
- if data:
- linked.setdefault(data, []).append(obj)
+ if obj.type == 'MESH':
+ linked[obj.data].append(obj)
for data, objects in linked.items():
face_verts = [axis for obj in objects
@@ -637,19 +637,11 @@ class MakeDupliFace(Operator):
mesh.polygons.foreach_set("loop_total", (4,) * nbr_faces)
mesh.update() # generates edge data
- # pick an object to use
- obj = objects[0]
-
ob_new = bpy.data.objects.new(mesh.name, mesh)
- base = scene.objects.link(ob_new)
- base.layers[:] = obj.layers
+ context.collection.objects.link(ob_new)
ob_inst = bpy.data.objects.new(data.name, data)
- base = scene.objects.link(ob_inst)
- base.layers[:] = obj.layers
-
- for obj in objects:
- scene.objects.unlink(obj)
+ context.collection.objects.link(ob_inst)
ob_new.instance_type = 'FACES'
ob_inst.parent = ob_new
@@ -659,6 +651,10 @@ class MakeDupliFace(Operator):
ob_inst.select_set(True)
ob_new.select_set(True)
+ for obj in objects:
+ for collection in obj.users_collection:
+ collection.objects.unlink(obj)
+
def execute(self, context):
self._main(context)
return {'FINISHED'}