VB.NET\C# Plugin - "Rhino.Geometry.Unroller" function

Trying to use the “Rhino.Geometry.Unroller” function. The function returns a different result than the function in “Rhino Script”.I don’t know why.

I am using “Rhino 5” and this example in VB.NET \ C #.

Results below.
For “Rhino Script” and “VB.NET

I attach a detail file.
detail.3dm (63.1 KB)

The original code doesn’t compile.
I changed “If rc IsNot Rhino.Commands.Result.Success” to “If rc <> Rhino.Commands.Result.Success”.

With default tolerance, the function does not work.
(“breps.Length” returns 0)
I changed to
unroll.AbsoluteTolerance = 0.01
unroll.RelativeTolerance = 0.11

Anyone know why this happens? :roll_eyes:
I would like it to return the same results as “Rhino Script”

Hi @Crash,

Using the UntrimAll command, you can see that the underlying surface extend far beyond the trimming boundaries of the Brep face. In this case, use BrepFaceList.ShrinkFaces to remove the portion of the surface that is unused.

Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result

  Const filter As ObjectType = ObjectType.Brep Or ObjectType.Surface
  Dim objref As ObjRef = Nothing
  Dim rc As Result = RhinoGet.GetOneObject("Select surface or polysurface to unroll", False, filter, objref)
  If rc <> Result.Success Then
    Return rc
  End If

  Dim brep As Rhino.Geometry.Brep = objref.Brep()
  If brep Is Nothing Then
    Return Result.Failure
  End If

  Dim in_brep As Brep = brep.DuplicateBrep()

  Dim unroll As New Unroller(in_brep) With {
    .AbsoluteTolerance = 0.01,
    .RelativeTolerance = 0.1,
    .ExplodeOutput = False

  Dim out_breps As New List(Of Brep)
  Dim out_count As Integer = unroll.PerformUnroll(out_breps)
  If out_count > 0 Then

    Dim attribs As ObjectAttributes = objref.Object().Attributes

    For i As Integer = 0 To out_breps.Count - 1
      doc.Objects.AddBrep(out_breps(i), attribs)
    Next i

  End If

  Return Result.Success

End Function

– Dale

1 Like

thank you for quick reply. I didn’t know this “BrepFaceList.ShrinkFaces”.


“PerformUnroll” must accept all 3 arguments.
It looks like you wanted to add result “unroll.PerformUnroll” to list.

i changed it

like this …

Dim out_breps As New List(Of Brep)
out_breps.AddRange(unroll.PerformUnroll(Nothing, Nothing, Nothing))
Dim out_count As Integer = out_breps.Count

now It works very well
thank you.

Hi @Crash,

The code I posted works in Rhino 6 - I should have mentioned this.

– Dale