Use TrimBrep

Dim strObject, strCutter

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.2 1

Just one post, please.

– Dale

When I use SplitBrep it creat 2 parts of the surface. But i don’t know identifier of 2 parts. Please help me.

Dim strBrep, strCutter, d
strBrep = Rhino.GetObject("Select brep to split", 24) 
strCutter = Rhino.GetObject("Select cutting brep", 24) 
d = Rhino.SplitBrep(strBrep, strCutter, True) 
Rhino.DeleteObject(d)

I want to delete 1 parts of “d” which created from splitBrep.

Hi.
When I use SplitBrep

if strBrep and Strcuter created from AddLoftSrf or AddSrfPt… then it is not successful.

But StrBrep and Strcuter = Rhino.GetObject(“Select”) then it is successful.

. Please help me.

Dim strBrep, strCutter, d
strBrep = Rhino.GetObject("Select brep to split", 24) 
strCutter = Rhino.GetObject("Select cutting brep", 24)
d = Rhino.SplitBrep(strBrep, strCutter, True)

Hi @cua54kttt,

Does this help?

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

– Dale

1 Like