Help Unselect Parent and(or) Children

Very simple questions:
I need two separate scripts with follow problems(things I dont know how to):
one)
How to deselect objects in my selection which are parents to any other objects

two)
How to deselect objects in my selection which are parents or children(just affected by any object)

I would be very gratefull for any help due to it's one of core elements in tool I'm working on

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kredka's picture

Great, works fine. Thankyou.

Great, works fine. Thankyou.

miauu's picture

Deselect all objects that are

Deselect all objects that are parent to any other objects. This includes objects that are children of other objects, but are parents of other objects.

(
	parentsArr = for o in selection where o.children.count != 0 collect o
	deselect parentsArr
)

Deselect all objects in selection that are parent or children of other object.

(
	parentsArr = for o in selection where (o.children.count != 0) or (o.parent != undefined) collect o
	deselect parentsArr
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.