Using Rhino3dm in Blender

Add this script to Blender and run it after importing a 3dm:

import bpy
import bmesh

sc = bpy.context.scene

for o in sc.objects:
    if o.type == 'MESH':        
        m = o.data
        bm = bmesh.new()
        bm.from_mesh(m)
        
        bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.001)
        
        bm.to_mesh(m)
        bm.free()
3 Likes

That destroys the custom split normals, and my point to @kalamazandy was that you can’t just “fix the normals up a bit”, not even with the weighted normal modifier, because you end up with this:

bild

But regardless, the even a straight up imported 3dm file has normal issues:

bild

Compared to inside Rhino:

bild

Compared to converted with Unreal Datasmith and imported into Blender:

bild

Sorry, again, a user shouldn’t have to do this. It should be done automatically with the retention of custom split normals. 3D Studio Max does this, and Unreal Datasmith does it too. It’s still a showstopper for me.

Is there a way to keep blender material and do not need to assign material again and again when re-import rhino model?

Ha, yes. I have made a similar script as well. And it is Not perfect. I need to at Least have it add the weighted normal as well. And I’d probably want to fix it up to actually ask the user about the smooth angle and merge threshold as well. And I think I’ll want it to work on only selected objects as well, in case you import just some new pieces or something. But this may help someone:

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 actually 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()

It has a few catches to not work on some other stuff, and I left a bunch of notes there, for myself because I’m new to that sort of thing. The first time I did it, I was trying to do it more like user based scripts. So it was just walking through exactly how you would do it all by hand. On 17000 pieces, blender did Not like it. lol

And you’re right. It could be Much better. The custom split normals don’t translate correctly. On a plain old fillet, not even next to a compound curve, you Clearly see a harsh seam before you rebuild normals. And that only works well if you also use weighted normals. It Can be “fixed up a bit” but each part would have to be fixed manually. And sometimes that also means either you have to use more mesh than you want, or manually create some loop cuts. And you can’t really just add loop cuts, because the mesh is Not ideal for polygon modeling. And don’t try and tell me that I should use the WIP quad remesh, because it has very limited uses where it gives you what you need.

Unfortunately, not everyone uses this sort of thing enough to justify the cost of datasmith. Although, Unreal has it built in with the design version, and That cost is low. I haven’t looked to see if you can import things to Unreal using that, then export that out cleanly to blender. It’s a bit of extra work and time, but if it’s nice and clean normals, then it may be a good low cost solution. Although, we were using Unreal just to look at models in VR. And now that blender has some of that limited functionality built in, it’s Much faster of a workflow. We had to optimize things a bit to get advanced materials working ok in Unreal on a GTX 2070 (and making advanced materials also took some time and the learning curve for Unreal is a bit steeper than blender I think.

Yes, with the 3dm plugin, there’s a checkbox for that. Check the box.
Warning, may only work if you haven’t renamed objects.

hi @nathanletwory,

I’m watching this thread to see if we will have a fully non-destructive workflow between Rhino<>Blender. Based on what folks are reporting here this is not the case.

Importing .3dm has a limitation that all Nurbs objects in Rhino are being meshed, correct? so there’s no way to bring them back to Rhino and have the original Nurbs objects, right?

Can you think of a way to come up with a fully non-destructive live-link workflow between Rhino and Blender? maybe using Rhino.Inside?

This is something extremely desirable and important for us for our entire visualization pipeline.

Thanks,

Gustavo

1 Like

I did but it didn’t work in 2.9

It is currently a one-way deal, the add-on is called import_3dm for that reason (and not livelink_rhino).

But for the nearish future I would like to put some time into exploring better pipeline integration between the two, preferrably indeed non-destructive.

Rhino.Inside is a good candidate, but unfortunately it causes Blender to crash due to OpenGL context conflicts. For this particular use I would like Rhino to completely disable its own OpenGL stuff, I’d be most interested in the geometry kernel. Rhino Compute looks like a better fit until the OpenGL trouble is fixed. This could work for a user with Rhino Compute running on their own machine as well.

The import_3dm add-on is at the moment mostly for bringing Rhino objects (meshed) into Blender for further usage in say animation or just rendering and post-pro work. It is pretty much one-lane.

I briefly touched upon collaborative environment in the topic Rhino Inside in Blender It is definitely something I want to work on/with again.

4 Likes

It only works when you change blender material data into the object

image

any ideas for fixing?

This is great to hear Nathan. I use Rhino and Blender daily. In the beginning I just used Blender for animation, however as I’ve learned Blender better, I’m now using it to model some objects and Rhino to model other objects within the same project, depending on which software is quickest for whatever I’m modelling. A non-destructive workflow (and Cycles material exchange) between the two softwares would be amazing.

Ryan

1 Like

could you help me? Because it doesn’t work.

when I try to import rhino files into blender it causes chaos. I think there should be some bugs.

It would be useful if you can share the file you’re trying to import. Then I can fix whatever is wrong.

1 Like

I uploaded on google drive

The chair imports just fine in Blender 2.90.1. I checked groups, nested groups and block instances in the import settings. In the attached screenshot I hid all block definitions. Maybe you need to do that too?

This is not the model you showed earlier, though.

1 Like

Try new file again. There is going to be scale and extra object issues.

here is the result

Did you hide all the block definition layers?

The small one is the correct one.

1 Like

yes l did. Did you get same result with new file?