Read Plugin Data from 3dm File

Hi,

If my plugin is already running and I am opening a new 3dm file - I can read plugin-related data with ReadDocument Sub.
But if required 3dm file is opened and I start my plugin afterward - how to check if file contains plugin data and if yes - read this data in a similar way as with ReadDocument?

Thanks,
Dmitriy

As far as I know, this is not possible to load the data after the file has been opened. What you can do is this:

File3dm f; // you should open the 3dm file that is already opened 
foreach (var pd in f.PlugInData)
{
    Guid id = pd.PlugInId;
    if (id == myPluginId)
    {
        // alert the user that they should re-open the file now that your plug-in is loaded
    }
}

Hi Menno,

Sounds reasonable. Thanks!

@dale - can you please confirm this?

Kinds regards,
Dmitriy

@dale or @stevebaer - can you comment, please?

Thanks,
Dmitriy

You shouldn’t have to worry about this. Your plug-in will automatically be loaded when Rhino encounters data written by it in the 3dm file.

Only in the case where a) the plug-in is not previously known by Rhino and b) gets loaded manually after a file containing data has been loaded do you need to do ask the user to re-load the file. Otherwise, the plug-in is indeed loaded on demand by Rhino.

Thanks guys.

Question related to this:
I would like to save current doc.

Dim opts As New FileWriteOptions()
opts.SuppressDialogBoxes = True
RhinoDoc.ActiveDoc.WriteFile(mypath, opts)

But still i need to press Enter before it saves:

Save file name <C:\Users\DSO007\Desktop\curproj.3dm> ( Version=6 SaveSmall=No GeometryOnly=No SaveTextures=Yes SavePlugInData=Yes Browse ):

@menno @stevebaer , what should I add in order to save in absolutelz silent mode/no @Enter@ confirmation?

Thanks,
Dmitriy

Why not script it using RhinoApp.RunScript("_-SaveAs "D:\temp\test.3dm" _EnterEnd");

Thanks,
this, of course, will work but I was just thinking when using SuppressDialogBoxes - saving should take place without extra confirmation. I guess using of RC doesn’t foresee using of Script.

Just would like to now if it is a Bug or not?

When saving a document, you should script the Save command using RhinoApp.RunScript…

1 Like

Thanks @dale

And when WriteFile to be used then?

Thanks,
Dmitriy

I’m not sure I can tell you - sorry…

Because 3dm is an open file format, there is the possibility to read/write outside of rhino, when using Rhino3dmIO. That’s when to use WriteFile.

Ok. Clear.
Thanks guys!