GH RenderContent adapter

Was working on grasshopper support for bella, and an experiment went in a more generic direction, yielding a ghpython script that can automatically expose any RenderContent-derived object:

I’m not sure if something like this may already exist, but the materials support in grasshopper seems pretty limited, so feel free to play around with it if you like:

render-content-adapters.ghx (621 KB)

The basic idea is that you have to create a ghpython node, and give it inputs named for the RenderContent fields, which you can find by enabling this option:

… and clicking View XML in the content editor:

You then paste the code (it is the same for any content type), and expose the fields you wish:

All of the inputs are set to List access (necessary, for example, to allow modulating values across a collection, as can be seen in the video), with no type hint, and you probably want to put this in a cluster so you can expose friendlier names, as shown above, and in the screenshot/video.

As you can see in the video, if you have an attribute like PBR base color, it will accept connecting either a color, or a reference, found by name, to some content in the model.

There are also a few helpers in the ghx, for choosing content, and/or creating it on demand. Note that when modulating values, it will produce numbered copies of the content.

On that, one of the more annoying things I found so far is that it appears content has to actually be contained in the rhino doc for it to work correctly, so if anyone knows a trick for avoiding that, it would be welcome.

Anyway, that’s about it for now, hope you can have some fun with this and let me know what you think.