Add reference to Rhino3dm

Hello,
I have just downloaded the newest Rhino3dm 7.7.0.
I tried to reference it in PythonEditor:

import clr

filepath = r"C:\rhino3dm\v7.7.0\rhino3dm.7.7.0\lib\net45\Rhino3dm.dll"
clr.AddReferenceToFileAndPath(filepath)

import Rhino3dm  # raises 'No module named Rhino3dm' error

I get such messages if .dll is blocked (it is not), or lacks some dependency.
Dependency walker shows that the only file missing is:

librhino3dm_native.dll

But I have that file in the same folder as ‘Rhino3dm.dll’.
I tried with having both ‘librhino3dm_native.dll’ x86 and x64 versions in the same folder.
Still it the module couldn’t be imported/
What could be the issue?
Any help is appreciated.

In order for this to work, you need to have two subdirectories next to the Rhino3dm.dll

  • Rhino3dm.dll
    |- Win32
    |— librhino3dm_native.dll
    |- Win64
    |— librhino3dm_native.dll

The Win32 and Win64 should have the librhino3dm_native.dll from the runtimes directory


In case you didn’t know, we have a native CPython implementation of rhino3dm available on pypi.org. This is not a .NET based solution and is designed to work with CPython
rhino3dm · PyPI

1 Like

Hi Steve,

Thank you for the detailed reply.
At the moment I am intersted in .NET version, but it’s good to know about the cpython one.

So the librhino3dm_native.dll for Win32 folder comes from:
rhino3dm.7.7.0\runtimes\win-x86\native folder, while the one for Win64 comes from C:\djordje\coding\libraries\rhino3dm\v7.7.0\rhino3dm.7.7.0\runtimes\win-x64\native?

image

If that is so, I still get the same error 'No module named Rhino3dm' after creating these two Win32 and Win64 folders with librhino3dm_native.dll in them.

Is there a way to identify why the error appears?

It might just be import Rhino

1 Like

Thank you Steve.
But with import Rhino how do I know if I am not importing Rhino3dm and not regular Rhino namespace?
When I print the names of all loaded references:
print [assembly.GetName().Name for assembly in clr.References]
I get:
['mscorlib', 'System', 'RhinoCommon', 'System.Windows.Forms', 'System.Drawing', 'RhinoPythonHost', 'Eto', 'Rhino.UI', 'Grasshopper', 'GhPython', 'Rhino3dm']
Based on that the import Rhino3dm should work?

Oh, I thought you were working in stand alone IronPython. There is no need that I know if to use Rhino3dm inside of Rhino. What are you trying to do?

1 Like

Hi Steve,
Yes, you are right. Sorry for not being precise from the very start. I intend to use Rhino3dm for an ironpython winforms application. I just wanted to write the code in RhinoPython editor, as I am used to it.
That was the whole idea, and not to use Rhino3dm inside Rhino along with regular Rhino namespace.

In that case, you probably just have to keep the clr.AddReference… line commented out while editing.

Rhino3dm and RhinoCommon both use Rhino as their base namespace and they were never intended to be in the same process.

1 Like

Thank you for the help and advice Steve.