1
$\begingroup$

I would like to change the hide_viewport state of a collection in a driver. It is unfortunately not possible to add a driver to a collections's states. (It is possible to do this on objects but not on collections.) The problem is that in the driver editor I can't assign a value to a variable (like var = 0 ) as this results in an "Invalid Python expression". Which is a bit silly as this is just a normal variable value assignment in python.

In an if statement in the driver editor one can assign a value (0 if whatever == something) but this refers to the value of the driven object. As the collection can't have a driver I would like to drive it's states by another object's driver. Is there any way to achieve this?

Basically recreating the bpy.data.collections["Collection_Name"].hide_viewport = True statement from a script in a driver. (I can't use a script as I intend to append the collections and the driver objects in an empty file. Or can I attach a script to an object so that the script also gets appended with the object?)

EDIT: This question is a follow-up to my question from yesterday: Geometry Nodes - Collection Info: turn off visibility of input collection It's about turning off a collection's visibility when it is affected by a "Collection Instance" geometry node, without any user interaction in the object lister.

EDIT 2: To make this question clearer using the example from my other question: Driver variables The expression 0 if var == 0 else 1 sets the value of the X Location of the Empty to 0 or 1. But what I would like to have is to set the value of the collection_variable to True or False. Like: (collection_variable = True) if var == 0 else (collection_variable = False) and this is what is unfortunately not possible.

If I understand correctly the variables here are read only and only help to determine the state of the object's attribute which has the driver. Is there any way to set other attributes? (Outside of the scope of the current driver?)

$\endgroup$
1
  • $\begingroup$ The Problem is, that I would like to import a Master collection together with the object which has the geometry nodes to alter the content of the collection. Then a user drops his collections under the imported collection and so all of his/her objects get's modified by the collection instance node by the imported objects geometry node. Unfortunately there is no automatic way of turning off the original collection content and only show the modifications done by the geometry node tree. This should be automatic, not requiring the user to manually turn off the collections visibility. $\endgroup$ Commented Dec 2, 2024 at 13:56

1 Answer 1

1
$\begingroup$

One possible workaround might be instancing and realizing the entire collection when some (the variable) condition is met. All your original collections can have visibility and selectability toggled off.

In a separate geometry nodes object, you could link a Menu Switch to the Group Input.

Then the Menu Switch can be controlled by the driver, and you can write several variables or expressions in the Driver Editor.

With the Menu Switch, you can have Collection Info A, B, C...etc (as many configurations as you want) and instance and replace different collections based on the location of an empty on the X axis as an example from your previous question.

enter image description here

enter image description here

enter image description here enter image description here

$\endgroup$
1
  • $\begingroup$ The user Gorgious shows how a custom property of a collection cam drive an object, but it is not clear how an object can drive a collection. blender.stackexchange.com/questions/237115/… $\endgroup$ Commented Dec 2, 2024 at 22:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.