I'm having trouble with a driver. I have the driver using a single property linked to a custom property. I want the driver to turn the visibility on when the custom property's value is "1", but turn the visibility off when the value is "0" or "2". What's the best expression to achieve this?
-
$\begingroup$ false if value == 1 else true ....or did i understand that wrong? $\endgroup$– ChrisCommented Apr 4, 2023 at 5:49
-
$\begingroup$ Hi Please use a title that reflects the content of the question. It should be descriptive but succinct, unique and identifying, summarizing the issue so that users can at a glance understand what your post is about. Use the edit link below your post and avoid anything not strictly essential to the post. Remember, your title is the first thing potential visitors will see, and makes your question findable for future users. See "What is the problem with posting an image or link and asking “How do I do this?"" $\endgroup$– Duarte Farrajota Ramos ♦Commented Apr 4, 2023 at 9:00
1 Answer
Visibility is a boolean value of True or False that can be represented by 0 and 1 as well. You can write a statement that would evaluate to True or False as an expression when driving it.
In your case you need an expression that would evaluate as False only when your custom property is 1. This is confusing since it's False for the object to be visible and True to hide. You are actually driving object.hide_viewport
or object.hide_render
properties even though in the UI you usually disable a checkbox to hide and enable to show.
So var != 1
will only return false when var is 1:
-
1$\begingroup$ There are convenient "copy as a new driver" and "paste driver" options under context menu (right-click). $\endgroup$ Commented Apr 4, 2023 at 9:58