Equivalent to RhinoDoc.Open

Hi

is there an equivalent to https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_RhinoDoc_Open.htm in c++?
Or how is the preferred way to open a file from a c++ plugin?

Thanks

Hi @dsw,

You can use CRhinoFileMenu::OpenFile. See rhinoSdkFileMenu.h for details.

– Dale

Hi @dale,

thank you for the fast reply. I tried to use CRhinoFileMenu::OpenFile but i’m not sure if i did it right.
To use it i derived from the CRhinoFileMenu and called the OpenFile method but i got always an error (in debug mode) like this:
image

Maybe it’s because everything is too nested and complicated. To explain a little bit: i made a CRhinoScriptCommand which opens a dialog (with SetEnableDisplayCommands) and within that i tried to open a file.

I reworked the whole functionality and now i use again RunScript which works now again pretty fine. Even though i would prefer a solid c++ method to open a file without a script.

Anyway thank you for your support

Hi @dsw,

Give this a try:

class CTestWolfgangFileMenu : public CRhinoFileMenu
{
public:
  bool Open(const wchar_t* pszPath);
};

bool CTestWolfgangFileMenu::Open(const wchar_t* pszPath)
{
  AFX_MANAGE_STATE(RhinoApp().RhinoModuleState());
  unsigned int rhino_doc_sn = OpenFile(pszPath, false, true, nullptr);
  return (0 != rhino_doc_sn);
}

But. scripting the _-Open command works just as well…

– Dale

Hi @dale
i tried it and it worked fine.
Thank you