Skip to main content
2 of 3
deleted 1 character in body
batFINGER
  • 85.1k
  • 10
  • 114
  • 244

Firstly, quite possibly, the issue re viewport via render is you need to drive the hide property as well. Simply right click copy on view_render driver, and right-click paste driver into the hide field to emulate hide_render behaviour.

A driver can only return a float (decimal) or integer (or bool (True, False)) type, therefore you can't return object references or name strings. What you can do though, is pass the name of an object to a driver expression.

To set a property on a parent using a driver.

def set_a_parent_property_too(name, property, value):
    object = bpy.data.objects.get(name)
    parent = object.parent
    setattr(parent, property, value)
    return True

#add to driver namespace
bpy.app.driver_namespace["set_a_parent_property"] = set_a_parent_property_too

Put in all the if object is None checks to code behaviour when object or parent is None.

The driver expression set_parent_property("Cube", "hide", True) will set hide to True on the parent and whatever the property being driven to True also.

batFINGER
  • 85.1k
  • 10
  • 114
  • 244