strObject = Rhino.GetObject("Select surface or polysurface to trim")
If Not IsNull(strObject) Then
strCutter = Rhino.GetObject("Select cutting surface or polysurface")
If Not IsNull(strCutter) Then
Rhino.TrimBrep strObject, strCutter
End If
End If
It’s always trim in I don’t like. The same picture 2. But i want to cutting in " Want to trim" the same picture 1.
I don’t know about it. Please help me.
Sub Main
' Local variables
Dim strCutter
Dim arrBrep, strBrep, arrPoint
Dim arrPieces, strPiece, strDelete
Dim arrCP, dblDistance, d
' Pick the object that cuts
strCutter = Rhino.GetObject("Select cutting brep", 24)
If IsNull(strCutter) Then Exit Sub
' Pick the object to trim
arrBrep = Rhino.GetObjectEx("Select brep to trim", 24)
If IsNull(arrBrep) Then Exit Sub
' Make sure the same object wasn't picked
strBrep = arrBrep(0)
If strBrep = strCutter Then Exit Sub
' Get the selection point
arrPoint = arrBrep(3)
' Split the object with the cutter
arrPieces = Rhino.SplitBrep(strBrep, strCutter, True)
If IsNull(arrPieces) Then Exit Sub
' Find the piece that is closest to the pick point
dblDistance = 100
strDelete = Null
For Each strPiece In arrPieces
arrCP = Rhino.BrepClosestPoint(strPiece, arrPoint, True)
If IsArray(arrCP) Then
d = Rhino.Distance(arrPoint, arrCP(0))
If (d < dblDistance) Then
dblDistance = d
strDelete = strPiece
End If
End If
Next
' Delete the trimmed piece
If Not IsNull(strDelete) Then
Call Rhino.DeleteObject(strDelete)
End If
End Sub