Open a rhino file using Rhino c++ SDK RhinoApp().FileOpen

I am using Rhino version (6.16.19190.7001, 7/9/2019) and I want to open a Rhino .3dm file by using Rhino C++ SDK (6.16.19190.07001).
I created a “Rhino 6 Plug-in” in visual studio 2017 and added below code to OnLoadPlugin method in plugin.cpp.

    ON_wString fileRead;
const char* file("D:\\rhinoPart.3dm");
const int nLen = strlen(file) + 1;
wchar_t filePath[100];
mbstowcs(filePath, file, nLen);
RhinoApp().FileOpen(filePath, true, true, &fileRead);

I built the solution and got below linking error,
1>OpenRhinoFilePlugIn.obj : error LNK2019: unresolved external symbol “public: unsigned int __cdecl CRhinoApp::FileOpen(wchar_t const *,bool,bool,class ON_wString *)” (?FileOpen@CRhinoApp@@QEAAIPEB_W_N1PEAVON_wString@@@Z) referenced in function “public: virtual int __cdecl COpenRhinoFilePlugIn::OnLoadPlugIn(void)” (?OnLoadPlugIn@COpenRhinoFilePlugIn@@UEAAHXZ)
1>D:\VW\Rhino\OpenRhinoFile\x64\Debug\OpenRhinoFile.rhp : fatal error LNK1120: 1 unresolved externals

I referred below link and FileOpen is available in CRhinoApp.

Do I need to add libraries to project General->Additional include directories or Linker->Input?
Am I missing something in my rhino plugin project?

Hi @sameer.kulkarni,

CRhinoApp::FileOpen is not a publicly exported function. That is, it is not decorated with a RHINO_SDK_FUNCTION macro. Thus, it cannot be called from a plug-in.

For an example of how to property open a 3dm file, see the following SDK sample.


Hope this helps.

– Dale

Thank you very much @dale for quick help!
I called RhinoApp().RunScript from the plugin OnLoadPlugIn and I could open the rhino part on plugin load.

However I still need a bit more help in knowing few things:

  1. I have a requirement where I need to open a rhino .3dm part from a C++ project (not rhino plugin project) in an already open Rhino session which is started from another rhino plugin project in the same solution. (Rhino plugin project and Non plugin project are part of the same solution)
  2. I tried with below call from the external project an exception got fired.
    RhinoApp().RunScript(0, static_cast<const wchar_t*>(script), 0);
    In external code I did not have CRhinoCommandContext object, so I passed in first parameter as 0 as I already had Rhino application opened by Rhino plugin project.
  3. Can I use Runscript to open the part file from the external project in the same solution in this case?
  4. Another question is can we call any Rhino SDK exported function from CRhinoCommand or CRhinoUtilityPlugIn classes through external project from the same solution?
  5. How to run Rhino command from external project so that Command class RunCommand gets called?

Please provide your guidance.
Thank you again!

Sameer Kulkarni

Hi @sameer.kulkarni,

This is not advised, as there is no guarentee Rhino is completely up and running when your plug-in OnLoadPlugIn override is called. Best to do this from a command initiated by the user.

I need a better understanding of what you are doing before I can help? What does, “open a rhino .3dm part from a C++ project” mean? Do you want to load a file into Rhino? Do you want open the file, in code, and read data from it? Is the other project a .EXE or a .DLL? Does the .DLL link with Rhino.lib? Some additional clarification and details would be helpful.

If the project links with Rhino.lib and opennurbs.lib, included with the Rhino C/C++ SDK, then yes.

In general, some addiitional information on what you are trying to do, and why, would be most helpful.


– Dale

Thank you @dale.
To be more precise, I have a solution with containing 2 DLL projects.

  1. Rhino plugin DLL project which would run rhino application
  2. DLL with UI having a button whose action click event needs to call Rhino script of opening the 3dm part.

First project is a DLL which contains a button. I need to handle on click event of the button and open a .3dm file from my local drive into already open Rhino session opened from the second project in the solution which is a Rhino plugin project.
If I write code to open 3dm file in rhino commands RunCommand method, would I be able to call RunCommand from the DLL of my other project?


Hi @sameer.kulkarni,

If the plug-in DLL references the other C++ DLL, and the other C++ DLL links with the Rhino SDK librarires, then the C++ DLL can call functions in Rhino, such a CRhinoApp::RunScript.

Does this help?

– Dale

Hi @dale,

Thanks for your continued support.
I think the Visual studio projects and DLLs part is creating confusion. I shouldn’t have mentioned that in the first place. Apologies. Lets keep it aside for now.

My main concern now is:
Can I open a .3dm file (saved on local drive), in an existing (already open) Rhino application session using RhinoApp().RunScript?
What would be the exact command to do so?

Rhino session would be launched using rhino executable through code. I want to open the rhino part file (.3dm) in the same already opened rhino application session using code (possibly by running some command in RhinoApp().RunScript()).

Script = “_-Open D:\part.3dm” always opens the file in new rhino session if script is run through code. If it is run through Rhino command prompt in UI then it opens the part in the same session as we are launching it from the session.

I need to use the already open Rhino application session.
Could you please help me with this problem?


Hi @dale,

I have created a command class which is derived from CRhinoScriptCommand.
class CCommandRhinoFileOpen : public CRhinoScriptCommand

I have added code to CCommandRhinoFileOpen::RunCommand for opening the part file but I am getting exception at line no. 35 in below snapshot. (highlighted)
I debugged and I have valid values for RhinoApp() and document->RuntimeSerialNumber().
What might be the reason for exception?

Exception details:

Hi @sameer.kulkarni,

How do you do this?

Keep in mind that Rhino SDK function will only work if you are running in-process. That is, if you launch Rhino from come other module, Rhino will be running out-of-process.

– Dale

Hi @dale,

I tried to run rhino exe and open part in session but did not succeed. However, when I am opening 3dm file with RunScript I am getting an exception as mentioned in my last comment.
Could you please go through the code snapshots attached in above comment and suggest why I am getting an exception?

Thank you,


Hi @sameer.kulkarni,

Without sample code I can run here, along with instruction on how to run it, I won’t be much help.

Did you try running the SDK, I referenced above, in your Rhino C++ plug-in?

– Dale