No module named rhino3dm

Hi,

Every time I try to use a code in Rhino Python Editor with import rhino3dm, It does not work.

Everything seems installed correctly, but I always get the following:

Message: No module named rhino3dm

Traceback:
line 1, in , “C:\Users\tenfo\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\PythonPlugins\1 (38038840-a03f-4099-bde0-f997783e1c14)\dev\wall_cmd.py”

Does anyone else get this message?

Best,

Felix

The rhino3dm Python module is a module intended for CPython usage, not IronPython that is embedded in Rhino. rhino3dm is a wrapper around OpenNURBS, the Rhino fileformat reading library. You have much more at your fingertips with the IronPython integration already in Rhino.

How did you install rhino3dm? What are you trying to accomplish?

Thank you Nathan, I think that interesting to know. I was trying to create a simple code that would create an architectural wall (with layers) from a internal polyline. I had found some stuff online and somehow assumed the rhino3dm was essential!

Thanks,
Felix

Hi Nathan,

I am so close to being able to do it in Iron Python, but seem to be stumbling at the final hurdle.

I am trying to:

  1. Get the user to select the polyline (no problem)
  2. Get the user to input width (no problem)
  3. Get the user to input height (no problem)
  4. Get the code to offset the existing line by the width (no problem)
  5. Get the code to select the selected curve and the offset curve and then loft them in a surface (no problem).
  6. Get the code to extrude that surface by the height (massive problem)

Any thoughts? Code and error messages below.

import rhinoscriptsyntax as rs

__commandname__ = "walltype4"

def create_wall():
    polyline = rs.GetObject("Select polyline", rs.filter.curve)
    if polyline is None: return
    
    width = rs.GetReal("Enter width", 0.1)
    if width is None: return
    
    height = rs.GetReal("Enter height", 0.1)
    if height is None: return
    
    offset_curve = rs.OffsetCurve(polyline, (0,0,0), width)
    if offset_curve is None: return
    
    lofted_surface = rs.AddLoftSrf(object_ids=[polyline, offset_curve], loft_type=3)
    if lofted_surface is None: return
    
    extruded_surface = rs.ExtrudeSurface(rs.coerceguid(lofted_surface, True), (0,0,height))
    if extruded_surface is None: return
    
    rs.SelectObjects([extruded_surface]) 
if __name__ == "__main__":
    create_wall()

Message: Parameter must be a Guid or string representing a Guid

Traceback:
line 890, in coerceguid, “C:\Users\tenfo\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py”
line 995, in coercecurve, “C:\Users\tenfo\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py”
line 1390, in ExtrudeSurface, “C:\Users\tenfo\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\surface.py”
line 21, in create_wall, “C:\Users\tenfo\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\PythonPlugins\Wall (c2b4f9e3-577e-4483-9a50-08459b41b9c9)\dev\walltype4_cmd.py”
line 27, in , “C:\Users\tenfo\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\PythonPlugins\Wall (c2b4f9e3-577e-4483-9a50-08459b41b9c9)\dev\walltype4_cmd.py”

I am not familiar with the rhinoscriptsyntax module, I believe that is @Alain who knows more here.

I primarily use just scriptcontext and directly the Rhino namespaces

thanks.

Hi @felixrothermel0,

Here’s a modified script. The error message you got related to the ExtrudeSurface second parameter, which needs to reference a curve. However there are some other issues, notably that ExtrudeSurface doesn’t seem to like working with my test polysurface (I started with a zig-zag line) so it was necessary to split the polysurface into individual surfaces before extruding - this is probably a bug as the polysurface extrudes fine using Rhino’s native extrude.

import rhinoscriptsyntax as rs

__commandname__ = "walltype4"

def create_wall():
    polyline = rs.GetObject("Select polyline", rs.filter.curve)
    if polyline is None: return

    width = rs.GetReal("Enter width", 0.1)
    if width is None: return

    height = rs.GetReal("Enter height", 0.1)
    if height is None: return

    offset_curve = rs.OffsetCurve(polyline, (0,0,0), width)
    if offset_curve is None: return

    lofted_surface = rs.AddLoftSrf(object_ids=[polyline, offset_curve], loft_type=3)
    if lofted_surface is None: return
    rs.DeleteObject(offset_curve) # tidy up
    
    lofted_surfaces = rs.ExplodePolysurfaces(lofted_surface, delete_input=True)
    if lofted_surfaces is None: return # split polysurface (extrude doesn't like polys: bug?)

    curve = rs.AddLine((0,0,0), (0,0,height)) # second param of extrude must be a curve
    ext_list = [] # will build list of extrusions to union later
    for ls in lofted_surfaces:
        extruded_surface = rs.ExtrudeSurface(ls, curve)
        if extruded_surface is None: return
        ext_list.append(extruded_surface)
        
    rs.DeleteObjects(lofted_surfaces) # tidy up
    rs.DeleteObject(curve) # tidy up
        
    if len(ext_list) > 1: # only boolean if more than one solid
        wall = rs.BooleanUnion(ext_list)
    else:
        wall = ext_list
        
    rs.SelectObjects(wall)
    
if __name__ == '__main__':
    create_wall()

HTH
Jeremy

Wow! Jeremy, thanks for this! its quite a workaround. I wonder what causes this bug as it was driving me nuts!