1
$\begingroup$

I started scripting in Blender not long ago. Even though I have read the API about the dependency graph I still have a question: What is the difference between an instance_object and a "normal" object in the dependency graph?

Following code is from template operator_modal_view3d_raycast.py

  def visible_objects_and_duplis():
    """Loop over (object, matrix) pairs (mesh only)"""

    depsgraph = context.evaluated_depsgraph_get()
    for dup in depsgraph.object_instances:
        if dup.is_instance:  # Real dupli instance
            obj = dup.instance_object
            yield (obj, dup.matrix_world.copy())
        else:  # Usual object
            obj = dup.object
            yield (obj, obj.matrix_world.copy())
$\endgroup$

1 Answer 1

1
$\begingroup$

The difference between a copied object and an instance is that the copied object is a separate entity that can have its properties, materials, modifiers etc. adjusted without affecting the object it was copied from. Instances of an object are practically identical except for their location, scale and rotation. Changes to the object affect all instances of it. For example a particle system that uses Render As: Object creates instances of an object for every generated particle.

The following ways exist to create instances of objects:

You can test this yourself by running the following script in the Scripting workspace. It will print the instances and objects that are present in the scene.

import bpy

depsgraph = bpy.context.evaluated_depsgraph_get()
for dup in depsgraph.object_instances:
    if dup.is_instance:  # Real dupli instance
        obj = dup.instance_object
        print(f"Instance: {obj.name}")
    else:  # Usual object
        obj = dup.object
        print(f"Object: {obj.name}")
print("---") 

More information about this topic can be found in the manual.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .