So basically i have a few cubes in my scene, i want to parent all the thin cubes to the empty in python, i know i would start with a sort of detection system in python to detect which cubes to select, however i have scene other answers on this topic syaing to just add child_of constraint, this will not work for me, is there a way to parent these objects to the empty properly in python?enter image description here

  • $\begingroup$ here's how to parent using python: blender.stackexchange.com/a/178871/142292 so you also want the algo to select the thin cubes? $\endgroup$ Aug 2, 2022 at 7:39
  • $\begingroup$ what if you set the names of the thin cube differently like "thin_cube.001", "thin_cube.002" etc is that feasible? so you loop through all objects with "thin_" in their name and select them. then select the parent last in the python code. $\endgroup$ Aug 2, 2022 at 7:44

1 Answer 1


This script uses the height of the "thin" cubes as condition to select them. In this case I've set the THRESHOLD_HEIGHT to 0.9 but adjust this value if need be. (I'm assuming that your cubes have a dimension of 2 meters)

import bpy


parent_obj = bpy.data.objects["Empty"]


for obj in bpy.data.objects:
    if obj.type == 'MESH' and obj.dimensions.z < THRESHOLD_HEIGHT:


bpy.context.view_layer.objects.active = parent_obj


If you want to base the selection algo of the "thin" cubes based on their name you can use this type of selection loop:

for obj in bpy.data.objects:
    if "thin_" in obj.name and obj.type == 'MESH':

You must log in to answer this question.

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