0
$\begingroup$

I'm trying to make a driver that gets the restrict viewport (hide property) and restrict rendering (hide_render property) properties from another object, as explained here.

enter image description here

1. No live updates ?

The above picture only shows a driver on the hide_render property, even if I did try with the hide property too.

  • hide_render : seems to work (objets are hidden when rendered);
  • hide : the outliner icons are not updated nor the objects are hidden in the viewport. Probably related to this bug ?

This is a known limitation of the current dependency graph (depsgraph).

Currently, the depsgraph can only represent and schedule up relationships on datablock level. Drivers are actually evaluated on the object level, and all in one go before any other data on the object gets evaluated. As a result, for drivers which operate on bones within the same armature that they read values from, the drivers are only able to see the result of the previous time that the pose was evaluated. In other words, you'll find a bit of lag in the updates.

2. Script to fetch a parent ?

While I have coding skills, I don't know anything about Python, and it's the first time I'm thinking about using a script in Blender.

Rather than setting manually an object for the "prop" value of the driver, is it possible to add a script that would fetch the object's parent ?

enter image description here

That script should get the closest parent having keyframes for the desired property.

I would be glad to have your thoughts about all of this !

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Hi, thanks for your reply ! I just updated my question to be more understandable, as I think we're not talking about the same thing... $\endgroup$ – gordie Nov 14 '15 at 8:38
  • $\begingroup$ You've posted a bug report from Nov 14 2013. I'm currently having no issues with driving the hide property of one object from the hide or hide_render property of another using 2.76.2. $\endgroup$ – batFINGER Nov 14 '15 at 9:15
1
$\begingroup$

To answer your first question, based on your screenshot your Python auto-execution is turned off. Hit CtrlAltU to get to the User Preferences, click the File tab, and check the box in the bottom left that says Auto Run Python Scripts. After this the drivers will update automatically.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.