Using Rhino3dm in Blender

Hi @fertig, thanks a lot for taking a look at this.

Yes, this is the problem I was referring to. I don’t know blender that much but couldn’t those instance definitions be put automatically inside a collection with visibility, render, and selection turned off for that collection. That way the user could focus just on the actual model.

Thanks,
José

@jespizua: looking at it i was actually wondering why i didn’t do it this way back then… I’ll try to fix it shortly. I’ll keep you posted. Thanks for pointing it out!

1 Like

Thanks Nathan this is great! I just installed and was able to import my .3dm file successfully. Until I found this particular comment in the Mcneel forums though, I couldn’t install properly because I was trying to install the import_3dm zip file on github, not realizing there was a newer import_3dm-v0.07-win zip file under /releases. I think mentioning the new file in the installation instructions could help people some people out (especially those unfamiliar with github like me). Thanks so much for your work!

Same here!

Anyway - thanks Nathan - this is a fantastic addon!

Glad you all like it. Huge thanks also to @fertig and @tom_svilans - they both implemented many features :slight_smile:

1 Like

I made, With Tons of help of “Testure” over at blender artists, a script that is Fairly required after you import. Rhino data in the viewport doesn’t have welded vertices. If you have a few objects, fine, merging those overlapping/double verts is pretty easy. But you then have to fix the normals as well, change to smooth shading, and turn on autosmooth with a reasonable angle.
So the script does all that for you.
Warning, it is designed to ignore your selection. It will do this to Every mesh object in your scene. If you’re trims small on a large face, you’ll need to adjust your mesh settings also to have more mesh also. You can do that a few ways, like limiting the max edge length, or adjusting the ratio (that’s my recommendation) to something like 4-6. When it subdivides to those small trims inside of your big surface, it will help by subdividing until the ratio of any triangles created are within that ratio. Imagine a rectangle who’s length is 1:6. That’s the maximum that triangle would fit in. The more square, the more mesh. This doesn’t always work though. Rhino mesh is never perfect. Booleans are never perfect when it comes to mesh, unless you designed them for mesh. So either you fix it manually after the fact, or you mesh the heck out of your model till it goes away.

But removing doubles is Absolutely necessary. So copy this into your text editor in blender and run it after import. Hint: you have to hit New in that view first. Then you can paste, and hit the play button.

import bpy, bmesh
from math import radians

SmoothAngle = 45
MergeThreshold = .0001
# I don't think this is needed so commenting out.   selection = bpy.context.selected_objects

ctx = bpy.context.copy()  #created context override variable. copies the context

smooth_radians = radians(SmoothAngle) #blender uses radians. So just converts the SmoothAngle to radians for the smooth angle number.

for ob in bpy.context.scene.objects:
    if not isinstance(ob.data, bpy.types.Mesh):  #this is a python function, not blender specific. If it's not mesh, return false, so continue.
        continue #this means if it isn't Mesh, continue to the next object without processing what's next in the for loop

    # create a context override so you don't need to handle selecting/deselecting objects to make the operators work correctly
    ctx['object'] = ob
    ctx['active_object'] = ob
    ctx['selected_objects'] = [ob]
    ctx['selected_editable_objects'] = [ob]
    bpy.ops.object.shade_smooth(ctx)

    ob.data.use_auto_smooth = True   
    ob.data.auto_smooth_angle = smooth_radians

    bm = bmesh.new()
    bm.from_mesh(ob.data)
    bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=MergeThreshold)
    bm.to_mesh(ob.data)
    bm.free()

If you want it to work on just a selection, you have to get rid of the context override. So just comment out line 17-20. It’s not perfect. I’m not sure you Actually need line 17-19. But I don’t know why line 20 works the way it does…because I’m not a programmer.

Anyway, it would be pretty cool if this action was built into the importer as an option. But I thought I’d share it with this group.

Oh, if you actually need some 45 degree angles to be sharp, you’ll have to override that number. Default is usually 30. But my Rhino models often have tiny fillets. I don’t mesh things by angle, but rather use maximum distance to surface. This way, Large sweeping curves get meshed a ton, but tiny fillets may only get 1-3 subdivisions. If it only gets 1, then I need that number to be 45.

1 Like

Nathan,

I have a question relating to the material slot coming in from Rhino.
Would it be possible to add a selection box to automatically assign a simple white default material to any object which has no material from Rhino assigned to it?
That way it would be easier to select all meshes “without” material after import.
There are situations when every object has to have a material assigned. One off them is for example Chip Walters Sketch Style add-on.

Thanks,

Fran

Hey @Prettypicturegirl,

Until the importer helps directly with that you can use this after an import to select materials that don’t have a proper material assigned:

import bpy
from bpy import data as D

meobs = [o for o in D.objects if o.type == 'MESH']
for meob in meobs:
    matcount = len(meob.data.materials)
    if matcount==0 or (len(meob.data.materials)==1 and not meob.data.materials[0]):
        meob.select_set(True)
2 Likes

Thank you very much, especially as you nourish hope to integrate that eventually in the future.

Kind regards,

Fran

I have started playing in Blender the past few days and have been very impressed with how far the software has gone from about 10 years ago which at that time I didn’t take very seriously with all its limitations when testing it back then.

Thats what brought me to this thread as I’m attempting to transfer a rhino/vray project over the blender for animation - only issue I’m seeing so far is the model is coming in very tiny vs just importing the OBJ file. Also - I’m noticing that mirrored seams have surface artifacts that show up in the final cycles render that don’t appear in the same render within rhino vray. theres a lot of components so I tested single objects between rhino and blender to see if a dense enough mesh gets rid of the problem, which it seems to work, however the whole model with components would be massive, and I’m not sure how to update the current scene with the remeshed model as I scaled everything up to fit the layout. Is there a way to update the model? I’m afraid to overwrite the file, reimport and have to rescale everything.

You should be able to set custom meshing settings on the document level. Then make sure you have all objects meshed (switch to say Rendered mode before saving).

Do the scaling in Blender instead of Rhino.

Thanks Nathan, Yeah I pretty much came to the same conclusion - again I’m only on like day 3 of blender so super easy things are difficult right now for me to do quickly lol

I’m just confused on why 2 identical meshes come in at different scales when exporting as OBJ vs 3DM if blender is using real units. Wasn’t sure if its something I did wrong or the plugin. I figure the former :smiley:

OBJ has no concept of units, but the 3dm importer tries to take it into account. Blender generally works in meters, so importing a 3dm file with model unit set to millimeters means a 10mmx10mm object will turn out very tiny in Blender.

interesting, didn’t know that. obj’s from rhino imported into zbrush modified and sent back to rhino are always exactly where they should be and proper scale. Well, once I figure out blender It won’t be a problem anymore I guess.

Hi, I’m currently trying to use this blender add-on to import rhino files, I’ve followed the steps in the read me. I go to preferences, addons, select the "import_3dm-master.zip, blender then says Modules installed from the zip location to scripts\addons,
however the addon name isn’t listed as an option to select in the official/community/testing columns. I restart blender, theres no 3dm option in the import, and no option to enable the addon in the preferences/addons library. I’m probably missing something very simple… sorry to bother you, would you know what I’ve done wrong here?

(I’m using Blender 2.83 on a windows10 machine)

Hi @natalie_stevens,

The instructions in the readme were outdated. I just updated them to reflect the current situation. The zip file you downloaded isn’t the correct one, instead you need to get the one for Windows from https://github.com/jesterKing/import_3dm/releases/latest

You only have to install this add-on, no need to do anything special other than enable the add-on after installing.

2 Likes

Thank you!

Have fun (:

Excellent plugin, but a warning to everyone. It uses Rhino viewport mesh. That means the edge of the trim surfaces, you’ll find that none of the vertices are joined. Basically, every surface from a polysurface is it’s own “island” in terms of blender objects. So it’s one object, but you’ll need to merge by distance in edit mode to fix the normals up a bit. And then also switch to smooth shaded with autosmooth turned on. And also you might need to delete custom normals if they exist (for some objects they exist, but I’m not sure when that happens yet).

So you’ll get your object in there, but you’ll find it needs some work if you want to make it pretty.
But it’s leaps and bounds better than OBJ.

We export for VR visualization purposes, so this is a showstopper for us. What you describe simply cannot be done in a reasonable amount of time for product visualization (if at all with very coarse meshes).

But we use Unreal’s Datasmith anyway… though this was an interesting curiosity to try.