Hi.
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.
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?
I would like it to return the same results as “Rhino Script”
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()
in_brep.Faces.ShrinkFaces()
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
attribs.RemoveFromAllGroups()
For i As Integer = 0 To out_breps.Count - 1
doc.Objects.AddBrep(out_breps(i), attribs)
Next i
doc.Views.Redraw()
End If
Return Result.Success
End Function