How to "instance" RenderContent?

The system I am integrating is nodal, so there are various material-related nodes, which are not materials, but which may be referenced by N materials. It’s not great to have to implement these as “materials” (or textures) in Rhino, but it appears that is the only way.

However, I have not yet figured how to make “instances” of these, as we see when choosing an existing Rhino texture or material, with the “share all settings” option checked. I can get the user’s intention from the ShowContentChooser function, but haven’t been able how to figure out how to implement the “instance” result.

The docs appear to indicate that a render content can be set as the child of another at most once, and this appears to be the case, so it seems either I am overlooking some method for instancing render content, or that it is not exposed in rhcommon (the c++ rdk MakeGroupInstance seems promising?).

Experimenting, I am able to put these in the document instead of parenting them to a render content, and then store their ID in a field for later retrieval, and this would sort of work, but it clutters up the material list with these non-materials, and the items do not appear parented (in tree view) under the materials that use them, as happens with “instanced” Rhino child contents. So I’d prefer to mimic the Rhino behavior with instancing of render content.

So I’d like to know if I’m missing something, or if this is perhaps not possible via (v6) rhcommon.

Hi @jdhill,

The C++ function MakeGroupInstance() is indeed the underlying method, but it was not exposed in V6 Rhino Common. We will soon add it to V7. Sorry for the inconvenience.

John

Not to be too demanding, but would it be impossible to get this into v6 in a SR? You can imagine I am looking at two quite different designs based on whether this exists or not, and aside from needing to do version-specific plugins, I’m not sure how compatibility would be handled (e.g. would need to always check if something had been referenced by guid in a field in the v6 plugin, and move it to child content? Or vice versa in the case someone saves to v6 from v7? And if so, not sure where this would be done).

Hi @jdhill,

Not too demanding; it was an oversight so yes, we will add it to V6 in (hopefully) the next service release.

John

That is really great, thanks again!

JD

Just committed the extra functions into 6.26 - you should have it on Wednesday.

https://mcneel.myjetbrains.com/youtrack/issue/RH-58383

  • Andy

Thanks, Andy!

Seems to be working fine, now I can get rid of some ugly temp code. :slight_smile:

        // The magical incantations ...

#if PLATFORM_MACOS
        pProc = bella.os.dlSym("_ZNK13CRhRdkContent17MakeGroupInstanceEv", pModule);
#else
        pProc = bella.os.dlSym("?MakeGroupInstance@CRhRdkContent@@UEBAPEAV1@XZ", pModule);
#endif