Sign up ×
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

I have a mesh, and it has children. One of it's children is an Empty. I know there is a way to select an object by type using Python (and there's a button for it too) and it's this:


I was wondering if there was a way to deselect an object by type. Basically, I want to select the children of the mesh, then deselect the empty.


share|improve this question
How about select inverse, select by type, select inverse? –  WChargin May 18 '14 at 4:30
That won't work, because I have other models in the scene. I just want the children of the current mesh without selecting the parent. I'll try to use one of the answers below. –  rioforce May 18 '14 at 21:21

2 Answers 2

up vote 5 down vote accepted

I would suggest not to use bpy.ops and instead access the selection directly.

# assume you the active object is the parent
for obj in bpy.context.object.children:
    if obj.type != 'EMPTY': = True

This is a little more clever, you can do it recursively (to select children's children).

def select_children_recursive(obj_parent):
    for obj in obj_parent.children:
        if obj.type != 'EMPTY':
   = True
# call the function

Similar to above but caller can define types not to select

def select_children_recursive(obj_parent, type_mask):
    for obj in obj_parent.children:
        if obj.type not in type_mask:
   = True
# call the function
select_children_recursive(bpy.context.object, {'EMPTY', 'LAMP'})
share|improve this answer
The first code box did the trick! –  rioforce May 18 '14 at 21:30
Well, I am still having issues. It won't allow me to use bpy.context in my importer script. Any ideas? –  rioforce May 18 '14 at 23:03
Please elaborate on "It won't allow me" –  ideasman42 May 19 '14 at 1:52
Sorry, should have been more specific. :P I get an error that says "Context is incorrect". I've searched around, but no luck... –  rioforce May 19 '14 at 18:14
@rioforce, Id need to see a link to full script and full stack trace. but this is probably another question. –  ideasman42 May 19 '14 at 23:45

For your use case, something like this will work

import bpy

# go through the children of the parent object
for child in["Cube"].children:
    # if the child is not an empty, select it
    if child.type != 'EMPTY': = True
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.