0
$\begingroup$

In Blender 2.81, I have a linked collection, and I want to apply a transformation over it. In the UI I just select the empty , so when I scale, translate or rotate the empty the liked data experiences the transformations too.

By the other hand, to do it with bpy, for objects is:

# object.type = 'MESH'
object.data.transform(transformMatrix)

But when I try to do it over an empty type:

# empty.type = 'EMPTY'
empty.data.transform(transformMatrix)

I get the error: 'NoneType' object has no attribute 'transform' because the empty's data property is None.

Is there a way to apply the transformations over empties? If there isn't how can I archive the same results?

I need to keep the collection linked because the source file changes quite often.

Thank you.

$\endgroup$

1 Answer 1

0
$\begingroup$

I found a solution:

You have to modify the empty's location, scale and rotation properties with the information contained in the Transformation Matrix. If you used vectors to build the Transformation Matrix, just apply them:

# For location add the vectors
empty.location = empty.location + traslationVect

# For scale assign the vector
empty.scale = scaleVector

If you have the transformation matrix you'll have to build the vectors based on the matrix's elements

PS: I didn't dive into rotations.

$\endgroup$

You must log in to answer this question.

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