Sketchup to Rhino

I’ve gotten good at converting Sketchup models in Rhino, thanks largely to this forum. Exploding the blocks, purging all the block references, rebuilding the meshes, merging the coplanar faces. It’s eventually started to become fairly smooth.

I need to export the Rhino models for colleagues to place back in overall Sketchup models, and this path isn’t resolved yet. The issue is that all methods so far result in disjointed meshes in Sketchup. (Tried .skp, .dxf, and .dae)

A work-around some have proposed is to make make every object in the Rhino file a block before exporting. Apparently that makes them workable in Sketchup. For a large film set, I’m working on the roofs of multiple buildings. The other portions of the buildings remain in Sketchup, where the complete objects will reside and the roofs will end up and to which they’ll regularly be exported, perhaps daily. A block-friendly export method makes some sense. I use a block for almost all multiple iterations of the same element on all projects. However, working on the many atypical and large one-off elements in complex buildings/projects – elements which often interrelate with others – benefits distinctly from having those atypical elements readily editable in common space and not being separate from one another in blocks. So I’d keep all those atypical objects as non-blocks. This would mean that before I export objects I need to make a block out of every object. As atypical elements accumulate this could become rather inefficient.

Maybe the above is the only way. But I’m hoping there are better solutions, and maybe some folks here can recommend some.

Hello,

I’m not sure if this will solve your issue, but I ran into a similar problem when I needed to move Rhino geometry into SketchUp for coworkers and wanted to avoid ending up with a bunch of disjointed meshes.

What worked for me was using ChatGPT to help write a quick Rhino script (I don’t know how to code myself) that converted all geometry into blocks while keeping them on their original layers. I then exported the model as an SKP.

Once in SketchUp, I used the Ruby Console (with another ChatGPT script) to “explode” the components and convert them into groups. I eventually turned this workflow into a plugin to streamline the process. Essentially, this approach turns all Rhino geometry into groups rather than components.

If you want to maintain some geometry as groups and some as components, you would need to do two separate imports, performing the “convert to groups” step before bringing in the second set. You can add this file to your PlugIns folder in SKP. Its not perfect and I do not know how to code but it does ‘function’

model = Sketchup.active_model
entities = model.active_entities
model.start_operation(“Convert Components to Groups Safely”, true)

Create a new tag for imported groups

new_tag_name = “Imported_Groups”
new_tag = model.layers.add(new_tag_name) rescue model.tags.add(new_tag_name)

Collect top-level component instances

components = entities.grep(Sketchup::ComponentInstance).dup
total = components.size
count = 0

components.each do |comp|
begin
parent_entities = comp.parent.entities

# 1. Create a new empty group in the same parent
new_group = parent_entities.add_group
new_group.layer = new_tag

# 2. Move the component instance into the new group
new_group.entities.add_instance(comp.definition, comp.transformation)

# 3. Delete the original component instance from parent
comp.erase!

count += 1
puts "Processed #{count}/#{total} components"

rescue => e
puts “Skipped a component due to error: #{e}”
end
end

model.commit_operation
UI.messagebox(“Conversion complete! #{count}/#{total} components wrapped in groups.”)

To get it to work you will need to copy this into notepad and rename the file with .rp at the end. There are other threads you can find on how to create a SKP plug in. I would use those for the steps and use this script if you’d like to try it.

Best,
Parker

1 Like

It doesnt look like to code coped in correctly. You Need to copy from “model = Sketchup.active_model” to “UI.messagebox(“Conversion complete! #{count}/#{total} components wrapped in groups.”)”

Hey Parker! Thanks. This is great I think.

If I’m following correctly, the script you’ve posted is for Sketchup to do a conversion.

I think I understand that the script for Rhino to convert all geometry into blocks isn’t posted, but maybe I can ask chatgbt to do it and see what I can get.

I Got this! But I am not sure if the part in italics goes into the python script or if it starts at “def”

Script:
import rhinoscriptsyntax as rs

def sanitize_name(name):

simple sanitization for block name

bad = r"\/:*?"<>| "
for ch in bad:
name = name.replace(ch, “_”)
return name

def objects_to_blocks_preserve_layer():
objs = rs.AllObjects(select=False, include_lights=False, include_grips=False)
if not objs:
print(“No objects found.”)
return

filter out existing block instances (we don’t convert instances)

objs = [o for o in objs if not rs.IsBlockInstance(o)]
if not objs:
print(“No non-instance objects to convert.”)
return

count = 0
for i, obj in enumerate(objs, 1):
if not rs.IsObject(obj): # object might have been deleted during process
continue

layer = rs.ObjectLayer(obj)
bbox = rs.BoundingBox(obj)
if bbox:
base = bbox[0] # use bounding-box minimum corner as block base point
else:
base = rs.coerce3dpoint((0,0,0))

block_name = “{0}_blk_{1:04d}”.format(sanitize_name(layer), i)

ensure unique block name

existing = rs.BlockNames()
if block_name in (existing or ):

append a counter until unique

n = 1
bn = “{0}_{1}”.format(block_name, n)
while bn in (existing or ):
n += 1
bn = “{0}_{1}”.format(block_name, n)
block_name = bn

create block definition from the single object

new_block = rs.AddBlock([obj], base, block_name)
if not new_block:
print(“Failed to create block for object: {}”.format(obj))
continue

delete original object (AddBlock keeps source objects)

try:
rs.DeleteObject(obj)
except:
print(“Warning: could not delete original object {}”.format(obj))

insert block instance at the same base point

instance_id = rs.InsertBlock(new_block, base)
if instance_id:

put instance on same layer

try:
rs.ObjectLayer(instance_id, layer)
except:
print(“Warning: could not set layer for instance {}”.format(instance_id))
count += 1

print(“Converted {} objects to blocks.”.format(count))

if _name_ == “_main_”:
objects_to_blocks_preserve_layer()

I figured out how to get it to run, but I get an error message “expected an indented block”.

I’ll indent if I know how to….

I’ve asked various iterations of chatGBT to create five or six python scripts. All of them fail to run and result in an error report. Not sure where to go from here.

Rhino Geometry to Blocks.py (1.8 KB)

This is the script that I use. Hope it helps!

Thanks very much Parker.

I got failure and error messages running that script as it was, but I put into ClaudeAI and (after about 9 iterations) I got a version which converts non-block polysurfaces and meshes into blocks. It leaves blocks as they are, as one would want. Through the process I got one which only works on the nurbs objects and leaves meshes alone. Great!

Rhino Polysurfaces to Blocks.py (3.4 KB)

RhinoPolysurAndMeshfToBlocks.py (3.9 KB)

1 Like

I am glad these scripts seems to be working for everyone. But i am also confused what is missing the current Rhino exporter that does not work as expected?

Can we get a couple files to see what the start and what the results are?

Since I’ve mostly worked in Rhino, switching to SketchUp felt a bit strange because of how it handles geometry. In Rhino, objects are automatically “grouped,” and you can directly edit edges, faces, or vertices using sub-object selection tools. In SketchUp, if you export a large Rhino model as-is, everything tends to merge whenever geometry touches. The script solves this by keeping the Rhino geometry intact and converting it into SketchUp “groups,” making the files much easier to work with. Essentially, it preserves the sub-object hierarchy by automatically creating groups in SketchUp that correspond to the original Rhino objects.

I dont have any example files I can share at this time but it applies to any file. In my case it was an architectural application.

Thanks Scott. I don’t think we can give you a file which on its own will evince the RHino-to-Sketchup issue this thread has come to focus on. The problem doesn’t become evident until the exported objects are worked with in Sketchup. (which I don’t have a copy of).

The problem is this: Unless an object is in a block in the originating Rhino file, our Sketchup-using colleagues’ attempts to work with it in Sketchup result in objects which quickly devolve into a constellation of disjointed polygons at best, and at worst a series of linear vertices with no selectable surfaces. If we have the problem identified correctly, I think any objects you export into Sketchup will have this issue.

We do create components of polysurface objects. this should allow them to be edited like Sketchup likes. But, that may only be in idea conditions.

I am not sure how disjointed meshes are being created, unless they are not joined in Rhino together.

For instance this table.

The top is a component (joined in Rhino terms) and the legs are 4 additional components. But, the table by push/pull and it sticks together in Sketchup.

Of course if the legs and table top should be moved around as one object in Sketchup, then the top and the legs should be a Block in Rhino as that should result in a component in Sketchup.

skptable

When I ran into this problem, I was exporting an entire building into SketchUp. My goal was to separate walls, roofs, floors, storefronts, etc., so the editing process would be easier. With the native export, all the geometry quickly became unmanageable because everything was joined.

Although this is an uncommon workflow, I needed to get geometry from Revit into SketchUp. I used Rhino.Inside.Revit (RiR) to extract the desired geometry, clean it up, convert it to blocks, and then export it to SketchUp. Once in SketchUp, I used the script I shared above to convert all the components into groups. I preferred groups over components because components make the file heavier, and I didn’t need all the extra attributes that come with them.

I personally prefer working in Rhino, but my coworkers prefer SketchUp, so I needed to deliver a file that was manageable for them.

Not sure if that all makes sense, but I hope it helps clarify the intent.

Love the Revit > RIR > SketchUp link. A lot that can happen there.

1 Like

Thanks Scott. That stool is pretty simple. In our workflow we are transferring entire house-sized buildings with a few period-specific detail elements, some of which are meshes previously imported into Rhino. It may be that the most severe issues in the Rhino-to-Sketchup flow are in the case of mesh objects being among those exported from Rhino into a .skp format. These objects seem worst from what I’ve seen looking over my Sketchup colleague’s shoulders. (On this show we Rhino users are currently in a different part of the city from the Sketchup users so unfortunately we can’t regularly inspect the results).

Sure, some decorative meshes will be super complicated in Sketchup. Generally shapes like that in Sketchup will be a problem anyway. But, three probably is ways to make them look beter in sketchup with welding, etc…..

Thankyou Scott, but apparently not. The polygons seem not to be even selectable in many cases (only the vertices), and some say (not sure it’s on this forum or not) that they arrive in Sketchup with the polygons micro-spaced so that the application doesn’t recognize them as touching, which obviates welding/joining. Even if they can be joined, another problem is that a large number of objects in a cluster - say a large amount of roof tiles, in our case - will become a constellation of separate polygons which defy discernment back into the objects of which they’re part, resisting reassembly/welding/joining into the discreet individual elements again. The issue is probably more important as a functional rather than appearance issue, as this makes it pretty much impossible for the objects to be selected/moved/edited in Sketchup.

Any examples when you come by them would be great to look at.

Thanks Scott. Attached beneath the image below are a Rhino file and the SketchUp file exported from it.

The black-lined objects were created in Rhino.

The other objects were first opened as SketchUp files into Rhino, and then scaled and moved in Rhino. (There are too many of these – the white ones are arrayed in the hundreds as roofing tiles – for it to be feasible to convert them to nurbs objects for use in Rhino without massive slowdown.)

These objects were first exported to a separate .3dm file from a block in the Rhino project file, and from that exported in .skp format.

The differing provenance of these objects may affect their performance after the Rhino>SketchUp trip. We haven’t tested that yet, though we understand the Rhino>SketchUp disjoint mesh issue is endemic to any meshes making the trip regardless of their provenance.

SketchUpExportDisintegratesMesh.3dm (1.2 MB)

SketchUpExportDisintegratesMesh.skp (393.4 KB)