I have a brep with just one surface that is trimmed. I would like to update the brep such that the surface’s x and y directions are inverted and swapped while still maintaining the trims. I’ve tried to figure it out myself but run into various road blocks, like the trims of a brep be readonly etc. I’m hoping someone could provide me some code to update a brep this way (using rhinocommon).
What about reversing the direction of just u so u points the other way? I see how to do this for a surface, but I’m hoping you can show me how to do this directly for a brep with a single trimmed surface while maintaining the trims.
That works though I loose the trims. I used it like this:
Dim BrepReversed = BrepOriginal.Faces(0).Reverse(0).ToBrep
The problem I’m running into is that trims are readonly so I can’t set them… and I tried AddTrimCurve and using the original breps trims but that didn’t work for me.
Any suggestions how I can reverse while maintaining the original trims?
Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
Dim go As New GetObject()
go.SetCommandPrompt("Select surface")
go.GeometryFilter = DocObjects.ObjectType.Surface
go.SubObjectSelect = False
go.Get()
If go.CommandResult() <> Result.Success Then
Return go.CommandResult()
End If
Dim brep_ref = go.Object(0)
Dim brep As Brep = brep_ref.Brep()
If (brep Is Nothing) Then
Return Result.Failure
End If
Dim brep_copy = brep.DuplicateBrep()
brep_copy.Faces(0).Reverse(0, True)
doc.Objects.Replace(brep_ref, brep_copy)
doc.Views.Redraw()
Return Rhino.Commands.Result.Success
End Function
I’m now trying to do something similar: Rebuild the single surface of a brep while maintaining the trims. I figured I’d post this here as the only difference is that I’m rebuilding rather than reversing directions.
For the “reverse” direction function, the “InPlace” boolean did the trick. But for rebuilding the surface, the “InPlace” option isn’t available. So I’m wondering if anyone has any suggestions on the best way to take a brep with a single trimmed surface and rebuild it while maintaining the trims.
I’m getting a result, though seems to be an invalid surface…
Below is my conversion to VB.net, perhaps I missed something… Attached is the trimmed surface I’m trying it on. Suggestions?
Thanks,
Sam
Dim objectRef As Rhino.DocObjects.ObjRef = Nothing
Rhino.Input.RhinoGet.GetOneObject(“select trimmed brep”, False, Rhino.DocObjects.ObjectType.Brep, objectRef)
Dim TrimmedBrep = TryCast(objectRef.Object(), Rhino.DocObjects.BrepObject).BrepGeometry
Dim face = TrimmedBrep.Faces(0)
Dim brep = face.ToBrep
Dim srf = brep.Surfaces(face.SurfaceIndex)
Dim nurb = srf.Rebuild(3, 3, 10, 10)
Dim RebuiltTrimmedBrep = Brep.CreateTrimmedSurface(face, nurb)
doc.Objects.AddBrep(RebuiltTrimmedBrep)