carson-katri / geometry-script

A scripting API for Blender's Geometry Nodes
https://carson-katri.github.io/geometry-script/
GNU General Public License v3.0
255 stars 25 forks source link

How to programatically set node input values for object or color picker #42

Closed rsaccon closed 9 months ago

rsaccon commented 10 months ago

I am specifically interested in setting the object in object_info(...) and setting a material in set_material(...).

Is this possible at all somehow ?

rsaccon commented 10 months ago

The best way to deal with this I have come up so far is just to put those data types with the interactive picker into the input group, so at least one has only to interact with the Geometry Nodes modifier panel and not with the visual nodes UI.

rsaccon commented 9 months ago

It is actually pretty simple, e.g. to set the material, something like this can be done:

input = ...   # that's well covered in geometry script source code for how to get a specific input
bpy.context.object.modifiers["GeometryNodes"][input.identifier] = bpy.data.materials["Material Roof"]

Of course, the material has to to be defined, either programatically (haven't tried that yet) or manually in the Properties / Material Panel and then it will be saved in the blend file of the object to which we apply the Geometry Nodes modifier.