Persistence of objects/values in scene files


#1

Hello,

How is scene file persistence of user/plugin objects/values handled in Rhino 6? A code example would be great.

Thanks!

Carsten


(Dale Fugier) #2

Hi Carsten,

You can user text or user data to pretty much any object in the document. You can also add data just to the document.

Here is a sample to give you an idea what’s possible.

https://github.com/dalefugier/SampleCsUserData

– Dale


#3

Hello Dale,

I got the persistence for our render options working. Now I am wondering how to best persist the viewport options. Do you have a suggestion for how to identify each viewport uniquely, and persist the settings so that they stick with the right viewport?


(Dale Fugier) #4

Hi Carsten,

Viewport have unique ids (UUIDs) that you can use to track them.’

– Dale


#5

Just to be clear, these UUIDs persist across sessions and layout changes?


(Dale Fugier) #6

Yes.

– Dale


#7

Great, thanks. I am just making the changes now, and hit one minor snag (for which I have a work-around): would you consider adding Guid -> GUID support for MethodGen?


(Dale Fugier) #8

MethodGen already supports UUIDs. Just decorate your “C” functions with ON_UUID.

RH_C_FUNCTION void MyFunction(ON_UUID uuid);

MethodGen will generate this:

internal static extern void MyFunction(Guid uuid);

Does this help?


#9

I don’t find the definition for ON_UUID, nor the Microsoft help page for this type. Where does this come from?


(Nathan 'jesterKing' Letwory) #10

ON_UUID comes from OpenNURBS (the ON is short for that).ON_UUID is pretty much an alias for GUID


#11

I am using Rhino.Collections.ArchivableDictionary to store things in, and using this to persist our settings. Currently, it appears that all set calls fail. Do you have any idea what we might be doing wrong, or might there be an issue in the current version? Our code looks like this:

    private RenderOptions()
    {
        m_dict = new Rhino.Collections.ArchivableDictionary();
        m_dict.Set(IFR_PRODUCTION_RENDERER, Native.Render.GetRenderer(ProdId));
        m_dict.Set(IFR_DESCALE_FACTOR, Native.Render.GetDescaleFactor());
        m_dict.Set(IRAY_MAX_SAMPLES, Native.Render.GetMaxIterations());
    }

The ALLCAPS values are strings. After these calls, the dictionary is empty.


#12

It appears to be because the strings are defined in the class like this:

    private static string IFR_PRODUCTION_RENDERER = "ifr_production_renderer";

It doesn’t work when the strings are static. Apparently there something I need to go read up on there.


(Dale Fugier) #13

Let me know if you need any help with this.

– Dale


#14

Adding readonly to the string constants fixed it. I am not sure why the initialisation order is so whacky without it, but I am looking at other things now. Thanks.