for i in instances:
obj_res = resources[i.prototype.name+".object"]
- st = scene_res.create_reference_statement("object", obj_res, i.name)
+ st = scene_res.create_reference_statement("object", obj_res)
+ if i.name:
+ st.append(i.name)
ss = Statement("transform")
import itertools
+import bpy
import mathutils
def is_same_object(obj1, obj2):
class Instance:
def __init__(self, obj, prototype):
- self.name = obj.name
- self.matrix_world = obj.matrix_world
- self.rotation_mode = obj.rotation_mode
- self.prototype = prototype
+ if type(obj)==bpy.types.DepsgraphObjectInstance:
+ self.name = None
+ self.matrix_world = mathutils.Matrix(obj.matrix_world)
+ self.rotation_mode = prototype.rotation_mode
+ self.prototype = bpy.data.objects[prototype.name]
+ else:
+ self.name = obj.name
+ self.matrix_world = obj.matrix_world
+ self.rotation_mode = obj.rotation_mode
+ self.prototype = prototype
class Scene:
def __init__(self, scene, obj_filter=None):
if o.data.use_shadow:
self.use_shadow = True
+ for i in scene.view_layers[0].depsgraph.object_instances:
+ if i.is_instance and i.object.type=='MESH':
+ self.add_instance(Instance(i, i.object))
+
proto_map = {}
for i in itertools.chain(self.instances, self.blended_instances):
p = proto_map.get(i.prototype)