I have a really weird issue with my script. It is extremely unpredictable and I have no idea why. Sometimes it works, sometimes it kinda works, and sometimes it doesn't work at all.
Here is what I want to do:
- I have an empty parent object that controls the all of its children
- I select that parent object, and then only select his children using the SHITFT+G shortcut, then select children
- Then I hide all of the children using the H shortcut
This is the script that I wrote:
def makeInvisible(ob): bpy.ops.object.select_all(action='DESELECT') ob.select = True bpy.ops.object.select_grouped(type = 'CHILDREN_RECURSIVE') for sel in bpy.context.selected_objects: sel.hide = True
As you can see, I will pass the the parent object as an argument to the function. The problem is that it doesn't really work, especially when I call it multiple times.
What am I doing wrong? Is there a better approach to my problem?