Skip to main content
deleted 74 characters in body
Source Link
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 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.

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.

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 get a property from a parent using a driver.

def get_parent_property(name, property, default):
    object = bpy.data.objects.get(name)
    parent = object.parent
    return getattr(parent, property, default)

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

The driver expression get_parent_property("Cube", "hide_render", True) will return the hide_render property of "Cube"'s parent object, or the default value True in the case there is no parent.

deleted 1 character in body
Source Link
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\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.

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.

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.

Source Link
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.