No, there isn’t a method to trim a Brep with a curve. In this case, try extruding the curve so it intersects the Brep. Then, use Brep.Trim
.
Hi, I tried as you said but the Brep.trim gives me an brep without image:
'Pick image
Dim dialog As New OpenFileDialog()
dialog.Filter = "Image Files|*.bmp;*.gif;*.jpg;*.jpeg;*.pcx;*.png;*.tif;*.tiff"
dialog.Title = "Select deck image"
Dim rc As DialogResult = dialog.ShowDialog()
If rc <> DialogResult.OK Then
Return Result.Cancel
End If
'Read image size
Dim myImage As Image = Image.FromFile(dialog.FileName)
Dim p0 As New Point3d(0, 0, 0)
Dim p1 As New Point3d(myImage.Size.Width, 0, 0)
Dim p3 As New Point3d(0, myImage.Size.Height, 0)
Dim plane As Plane = New Rhino.Geometry.Plane(p0, p1, p3)
'add the pictureframe
Dim MyPictureFrameID As Guid = doc.Objects.AddPictureFrame(plane, dialog.FileName, False, myImage.Size.Width, myImage.Size.Height, True, True)
Dim MyPictureFrameObj As RhinoObject = doc.Objects.Find(MyPictureFrameID)
Dim MyPictureBrep As Rhino.Geometry.Brep = TryCast(MyPictureFrameObj.Geometry, Rhino.Geometry.Brep)
doc.Views.Redraw()
'ask for rotate?
''Scale the picture Frame
'MyPictureFrameObj.Geometry.Transform(Geometry.Transform.Scale(p0, 1))
'doc.Views.Redraw()
'Pick the cutting rectangle
Dim corners As Point3d()
Dim res As Result = Rhino.Input.RhinoGet.GetRectangle(corners)
If res <> Result.Success Then
Return res
End If
Dim CuttingPt0 As Point3d = corners(0)
Dim CuttingPt1 As Point3d = corners(1)
Dim CuttingPt3 As Point3d = corners(3)
Dim CuttingPt2 As New Point3d(CuttingPt1.X, CuttingPt3.Y, 0)
Dim TrimmingRect As New Rhino.Geometry.Rectangle3d(plane, CuttingPt0, CuttingPt2)
'Create the trimming Brep
Dim TrimmingBrep As Brep = Extrusion.Create(TrimmingRect.ToNurbsCurve.DuplicateCurve(), 100, False).ToBrep
TrimmingBrep.Translate(0, 0, -50)
Dim TrimmingBrepId As Guid = doc.Objects.AddBrep(TrimmingBrep)
'trim the pictureframe
doc.Objects.Add(MyPictureBrep.Trim(TrimmingBrep, 0.001)(0))
'remove the trimming surface
doc.Objects.Delete(TrimmingBrepId, True)
doc.Views.Redraw()
This add a new Brep
to the document. But where is the original object’s attributes, which contain the material, texture mapping, etc?
Try passing the original object’s Attributes
to ObjectTable.Add
.
You might use ObjectTable.Replace
instead.
– Dale
Hi Dale,
Thank you so much for your help this is perfect!