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 setget a property onfrom a parent using a driver.
def set_a_parent_property_tooget_parent_property(name, property, valuedefault):
object = bpy.data.objects.get(name)
parent = object.parent
setattrreturn getattr(parent, property, valuedefault)
return True
#add to driver namespace
bpy.app.driver_namespace["set_a_parent_property"]driver_namespace["get_parent_property"] = set_a_parent_property_tooget_parent_property
Put in all the if object is None
checks to code behaviour when object or parent is None.
The driver expression set_parent_propertyget_parent_property("Cube", "hide""hide_render", True)
will set hide to True onreturn the hide_render property of "Cube"'s parent and whateverobject, or the property being driven todefault value True alsoin the case there is no parent.