So basically, I have a bunch of Lego bricks in my blender scene, they have different sizes, colours, etc. I was wondering if it was possible to set up some kind of detection system in python, where it can see the dimensions of each brick and rename the bricks according to those aspects.

for example if I had a 2 x 4 x 6 plate brick, python would recognise that it is a plate of that dimension and rename it to '2x4x6_plate.'

So, could it be done?enter image description here

  • $\begingroup$ You can check their dimensions and rename them accordingly $\endgroup$
    – Karan
    Jul 26, 2022 at 8:40
  • $\begingroup$ This might help get you started: blenderartists.org/t/… $\endgroup$ Jul 26, 2022 at 8:40

1 Answer 1

import bpy

for object in bpy.context.selected_objects:
    dimensions = object.dimensions
    if dimensions.x == 2 and dimensions.y == 4 and dimensions.z == 6:
        object.name = '2x4x6_plate'
        if object.type == 'MESH':
            object.data.name == '2x4x6_plate'
  • $\begingroup$ thank you very much:) $\endgroup$ Jul 26, 2022 at 9:17

You must log in to answer this question.

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