5
$\begingroup$

I'm trying to get the dimensions (bounding box) from a linked object in python, but all the methods to commonly get the measures give me a zero vector.

bpy.data.objects['Linked_Object'].dimensions
# (0.0, 0.0, 0.0)

bpy.data.objects['Linked_Object'].bound_box
# ((0.0, 0.0, 0.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0))

I imagine is because the object is an empty, so it does not have dimension. I suppose there is a way to access the underlying information of the linked object but I cannot find a way to do it.

I have to keep the object linked, I cannot make a local copy because it can be modified in the source file.

Any Ideas how to do it?

Thank you.

$\endgroup$
0

1 Answer 1

5
$\begingroup$

For a linked collection instance

Pertaining to 2.8x

Example below. Collection instance "Cube.001" is linked from library "Cube.blend" where it belongs to collection "Cube"

>>> C.object
bpy.data.objects['Cube.001']

>>> C.object.type
'EMPTY'

>>> C.object.library
bpy.data.libraries['CUBE.blend']

Notice the collection is linked too

>>> C.object.instance_collection
bpy.data.collections['Cube']

>>> D.collections['Cube'].objects[:]
[bpy.data.objects['Cube']]

The dimensions of the individual objects in the group can be found via

>>> for o in C.object.instance_collection.objects:
...     o.name, o.type, o.dimensions
...     
('Cube', 'MESH', Vector((2.0000009536743164, 2.0000009536743164, 2.0)))

which could be used to make a "virtual" bounding box for the collection.

How to have a boundary box around a whole group instance?

Similarly for linking the collection and instancing from local blend.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much! Just if there is someone with my low bpy skills: C = bpy.context and D = bpy.data (took me more than I'd like to admit). $\endgroup$ Commented Jan 10, 2020 at 15:52

You must log in to answer this question.

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