Using Rhino3dm in Blender

Hi @nathanletwory,
just stumbled across your Blender 3dm importer video via Luis’s tweet and I’m completely blown away! This seems to be the link that I wished to have for years now… Did the transport via FBX and OBJ until now but it always was some kind of a hassle.
Do you plan on extending that plugin (Layers/Materials/Blocks/Blender2.8)? This would of course be amazing - but if not I would try to see where I can get with my poor python skills :slight_smile:
Anyway, I tried to jump right in and see if I could at least get where you are in the video. But I already failed to understand how to install rhino3dm.py to Blender’s Python.
Could you maybe give a short introduction on how to make Blender Rhino-ready?
I’m really keen on getting into this stuff :smile:
Thank you!

2 Likes

I’m right now typing on a simple importer into Blender. I’ll add features when rhino3dm.py exposes the functionality. I already have importing into Blender 2.8 (not sure what video was tweeted and where), but it isn’t a nice add-on yet.

Right now it is relying on render meshes being saved into the file, but who knows what the future holds. Especially for those who have a Rhino license I think we can do great things using the compute bit.

When I have some time I’ll type up instructions how to get things up-and-running in Blender.

10 Likes

Thank you for the fast reply, @nathanletwory!
Very much looking forward to what will be possible with this :blush:
BTW it was this video which looked much like 2.79 to me :slight_smile:

Unfortunately I could not stop trying to make it work and you mentioning Blender 2.8 was a breakthrough for me: As 2.8 is built against Python 3.7 and one flavor of rhino3dm.py is as well, I was able to install the latter to 2.8’s bundeled Python. Now I can import rhino3dm in Blender and load a .3dm file!! Amazing :slight_smile:

But unfortunately object attributes don’t seem to expose any Properties to me atm:

from rhino3dm import *
import requests
req = requests.get(“https://files.mcneel.com/TEST/Rhino Logo.3dm”)
model = File3dm.FromByteArray(req.content)
for i in range(len(model.Objects)):
print(model.Objects[i].Attributes.Name)

If I run this snipped (borrowed and adapted from the rhino3dm.py pip page), I get the following Error:

“AttributeError: ‘rhino3dm._rhino3dm.ObjectAttributes’ object has no attribute ‘Name’”

If I dir the Attributes, I only see Decode and Encode Methods exposed.

print(dir(model.Objects[i].Attributes))

returns

[‘Decode’, ‘Encode’, ‘class’, ‘delattr’, ‘dir’, ‘doc’, ‘eq’, ‘format’, ‘ge’, ‘getattribute’, ‘gt’, ‘hash’, ‘init’, ‘init_subclass’, ‘le’, ‘lt’, ‘module’, ‘ne’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘sizeof’, ‘str’, ‘subclasshook’]

Any idea what went wrong?
Probably I should just give you guys some more time to stabilize everything but I’m just way too excited :smile:
Please excuse my hardheadedness :slight_smile:

You should check Luis’ latest tweet: https://twitter.com/luisfraguada/status/1053368422254497792 :smiley:

That is Blender 2.80 there. With a File > Import entry!

Anyway, I built from the repository, using latest master, since that is needed for accessing render meshes of a 3dm.

1 Like

Also I just pushed the current status I have to this repo:

1 Like

Sweet! Can’t wait to get my hands on it…
Wow, there it is already! Amazing, thanks Nathan!
Now I’ll just have to get rhino3dm.py built… Let’s see :slight_smile:

On the Mac I just built from source, then looked where rhino3dm/__init__.py and the necessary shared lib live, copied those into the blender bundle to the appropriate place. Same should work for Linux and Windows.

Note that Blender 2.80 uses Python 3.7.

Thanks a lot for those tips! Will see how far I can get :slight_smile:

Crude support for importing layers added

Currently the import code creates a top-level collection “Rhino 3D”. Under that are the layers. I haven’t looked into parent and child layers yet, so if there is any such structure it is currently lost. But it should be easy to add that, since it is easy to link collections (the new approach to layers - objects belong to one… or more!.. collections) around.

4 Likes

Wow, this grows incredibly fast :slight_smile: Really cool!!

Unfortunately I had no luck yet building rhino3dm.py here
(I have to admit that I’m not too experienced in building from source… )

I was able to clone the repo, installed Visual Studio 2017, Python 3.7 and CMake as explained here
But when I start building I get the following errors:

$ python build_python_lib.py
CMake Error at CMakeLists.txt:3 (project):
  Generator

    NMake Makefiles

  does not support platform specification, but platform

    x64

  was specified.


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/romua/rhino3dm/src/build/py37_64bit/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
  File "build_python_lib.py", line 72, in <module>
    compilebinaries()
  File "build_python_lib.py", line 25, in compilebinaries
    for line in fileinput.input("_rhino3dm.vcxproj", inplace=1):
  File "C:\users\romua\appdata\local\programs\python\Python37\lib\fileinput.py", line 252, in __next__
    line = self._readline()
  File "C:\users\romua\appdata\local\programs\python\Python37\lib\fileinput.py", line 339, in _readline
    os.rename(self._filename, self._backupfilename)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden: '_rhino3dm.vcxproj' -> '_rhino3dm.vcxproj.bak'

Is it possible to see what I’m doing wrong here?
If not - I’ll just have to wait patiently until the next pip version is going to be released.
Although building it by myself wold be really nice as well… Hmm :slight_smile:
Thank you anyway for your efforts, Nathan!

Did you start the Visual Studio command prompt? That should set all environment variables for you. Just make sure you can run your py3.7 from that as well, and all should be fine. I haven’t done this on Windows yet, so I’m not entirely sure - I know this works on MacOS and Linux.

Btw, if and when you get the module up and running feel free to fork import_3dm, and create pull requests.

At least some work towards making it a well-behaved add-on is necessary. (bl_info etc)

Nathan is working too fast and is using portions of rhino3dm.py that aren’t available in the PyPi distribution yet :slight_smile: Hopefully we’ll have a new version up on PyPi soon so you won’t have to deal with compiling the source yourself.

Hmm… no luck there… Getting the same errors with Developer Command Prompt :frowning:

Wow, sweet, let’s see how much I can contribute :slight_smile:
My Python skills are not exactly brilliant - yet… But I’m eager to learn :smile:

I see NMake is getting invoked. You probably need to also install make on your computer.
http://gnuwin32.sourceforge.net/packages/make.htm
and ensure that it is on your path.

I may be able to make this work with NMake, but I haven’t gottent around to that yet.

Thank you @stevebaer!
A new PyPi version would of course be much appreciated!
Although now I have to say that I wouldn’t be sad if I could get it to build straight from source.
Curiosity is definitely awoken! :smile:

Thanks, I’ll try that…
No hurry, as I said, I’m just too excited for all these possibilities :slight_smile:

Hmm… Unfortunately still getting the same error after installing Make…
NMake still seems to be used…
Probably I should just wait for the PyPi :slight_smile:

Hi @romio82,

Just curious, you do have Visual C++ 2017 installed, correct?

– Dale