UnrollSrf bug

Hi guys,

I have a surface which acts weird when I unroll it using RhinoCommon. It’s easy to recreate using Python though. Run the following script on the surface in the file below:

import rhinoscriptsyntax as rs

obj = rs.GetObject()


The left is the result I’m getting, notice the odd bump that shows up. This doesn’t happen when using the regular Rhino UnrollSrf command, but I cannot use that. Is this a bug or is there a way to prevent this from happening?

210908 UnrollSrf bug.3dm (181.6 KB)

If you rebuild the surface before trying to unroll it, the inconsistency seems to disappear!

1 Like

@wfcook can you take a look at this?

@stevebaer yes I will look right now

Thanks for the suggestion, but it’s not so much about workarounds since it works fine with the default Rhino unrollsrf command so I’d expect this to work the same using the RhinoCommon method. I use it in a plug-in for a client and I cannot rebuild every surface that gets chosen as input for the command.

This purely speculative, but in RhinoCommon there are two constructors for the Rhino.Geometry.Unroller class (cf. docs). One takes in a Rhino.Geometry.Brep and the other one a Rhino.Geometry.Surface.

Now, in rhinoscriptsyntax the first thing that rs.UnrollSurface() does, is cast the surface to a brep, and then it intialises a new Rhino.Geometry.Unroller() with that brep.

def UnrollSurface(surface_id, explode=False, following_geometry=None, absolute_tolerance=None, relative_tolerance=None):
    """Flattens a developable surface or polysurface
      surface_id (guid): the surface's identifier
      explode (bool, optional): If True, the resulting surfaces ar not joined
      following_geometry ({guid, ...]): List of curves, dots, and points which
        should be unrolled with the surface
      list(guid, ...): of unrolled surface ids
      tuple((guid, ...),(guid, ...)): if following_geometry is not None, a tuple
        [1] is the list of unrolled surface ids
        [2] is the list of unrolled following geometry
      import rhinoscriptsyntax as rs
      surface = rs.GetObject("Select surface or polysurface to unroll", rs.filter.surface + rs.filter.polysurface)
      if surface: rs.UnrollSurface(surface)
    See Also:
    brep = rhutil.coercebrep(surface_id, True)
    unroll = Rhino.Geometry.Unroller(brep)
    unroll.ExplodeOutput = explode
    if relative_tolerance is None: relative_tolerance = scriptcontext.doc.ModelRelativeTolerance
    if absolute_tolerance is None: absolute_tolerance = scriptcontext.doc.ModelAbsoluteTolerance
    unroll.AbsoluteTolerance = absolute_tolerance
    unroll.RelativeTolerance = relative_tolerance
    if following_geometry:
        for id in following_geometry:
            geom = rhutil.coercegeometry(id)
    breps, curves, points, dots = unroll.PerformUnroll()
    if not breps: return None
    rc = [scriptcontext.doc.Objects.AddBrep(brep) for brep in breps]
    new_following = []
    for curve in curves:
        id = scriptcontext.doc.Objects.AddCurve(curve)
    for point in points:
        id = scriptcontext.doc.Objects.AddPoint(point)
    for dot in dots:
        id = scriptcontext.doc.Objects.AddTextDot(dot)
    if following_geometry: return rc, new_following
    return rc

Maybe something goes astray during the conversion from surface to brep?
Why they don’t use the surface unroller that’s readily available in the API instead, I have no clue. :slight_smile:

Maybe you could try that?

1 Like

Nope, happens for that one too!

Also with the Unroll component from OpenNest!

1 Like

@siemen and @stevebaer I believe this was fixed in RH-64960 and that it will be in Rhino 7.11 which should go out on September 14th.

1 Like