WOW, this is an awesome script!! Im trying to turn it into a button for easy access. And Im in way over my head. LOL

I tried: https://wiki.mcneel.com/_detail/legacy/en/edittoolbarbutton2.gif?id=rhino%3Amacroscriptsetup

But what part must of the script must I paste in? Pascal or anyone. Im really a complete armature.

Also Pascal cant you please write this into a tool for grasshopper?

**Script :**

Option Explicit

âScript written by Pascal

â RMA

âScript version Wednesday, May 01, 2013

Rhino.AddStartUpScript Rhino.LastLoadedScriptFile

Rhino.AddAlias âNotcherâ, â_NoEcho _-Runscript (Notcher)â

'Cuts two intersecting panels with notches for assembly. No clearance.

'Call Notcher()

Private OldClear

If isEmpty(oldClear) Then

oldClear = 0

End If

Sub Notcher()

```
Dim P1, P2
Dim aP, aUsed(), n
n = 0
P1 = Rhino.GetObject("Select the first panel.", 16, True, True)
If isNull(P1) Then Exit Sub
Dim dblClear: dblClear = Rhino.GetReal("Add clearance? Enter 0 for none.", oldClear)
If isNull(dblClear) Then Exit Sub
OldClear = dblClear
Do
Do
P2 = Rhino.GetObject("Select an intersecting panel to notch. Press Enter when done.", 16, False, True)
If isNull(P2) Then Exit Sub
Loop Until P1 <> P2 And Not IsStringInArray(P2, aUsed, 0)
Rhino.SelectObject P1
Rhino.EnableRedraw False
aP = MakeNotch(array(P1, P2), dblClear)
P1 = aP(1)
ReDim Preserve aUsed(n)
aUsed(n) = aP(0)
n = n + 1
Rhino.EnableRedraw True
Loop Until IsNull(P2)
```

End Sub

Function MakeNotch(aPanels, dblClear)

```
Rhino.EnableRedraw False
Dim aInt: aInt = Rhino.IntersectBreps(aPanels(0), aPanels(1))
If Not isArray(aInt) Then
Rhino.EnableRedraw True
Exit Function
End If
Dim aExp: aExp = Rhino.ExplodeCurves(aInt, True, True)
Dim aLongest: aLongest = SortCurvesByLength(aExp)
If isArray(aLongest) Then
Dim Bound: Bound = UBound(aLongest)
If Bound < 7 Then Exit Function
Else
Exit Function
End If
Dim longest: longest = aLongest(bound)
Dim MidPlane: MidPlane = rhino.PlanefromNormal(Rhino.CurveMidPoint(longest), Rhino.VectorCreate(Rhino.CurveStartPoint(longest), Rhino.CurveEndPoint(longest)))
' drawPLaneFrame aPlane, 10
Dim aBB: aBB = Rhino.BoundingBox(AExp, MidPlane)
' Dim midPlane: midPlane = Rhino.RotatePlane(aPlane, 90, aPlane(2))
Dim aBaseCrv
ReDim aBaseCrv(Ubound(aLongest)-4)
Dim i
Dim Xform: Xform = Rhino.XformPlanarProjection(MidPLane)
For i = 0 To Ubound(aLongest) - 4
aBaseCrv(i) = Rhino.TransformObject(aLongest(i), Xform)
Next
Dim sBaseCrv: sBaseCrv = Rhino.JoinCurves(aBaseCrv, True)(0)
Rhino.SimplifyCurve sbaseCrv
If dblClear <> 0 Then
Dim aOffset: aOffset = Rhino.OffsetCurve(sbaseCrv, Rhino.PointAdd(MidPlane(0), Rhino.VectorScale(MidPlane(1), Rhino.Distance(aBB(0), aBB(6)))), dblClear, MidPlane(3))
End If
Rhino.DeleteObject sbaseCrv
sbaseCrv = aOffset(0)
Dim CutterBase:CutterBase = Rhino.AddPlanarSrf(sBaseCrv)(0)
'Dim Dist: Dist = Rhino.Distance(aBB(0), aBB(6))
' Dim aBase: aBase = Rhino.CurveMidPoint(longest)
'aPlane(0) = abase
Dim vec1, vec2
'drawPLaneFrame aPlane, 10
midPlane(0) = Rhino.CurveMidPoint(longest)
Vec1 = Rhino.VectorScale(Rhino.VectorCreate(Rhino.CurveEndPoint(longest), MidPlane(0)), 1.25)
vec2 = Rhino.VectorReverse(Vec1)
path1 = Rhino.AddLine(MidPlane(0), Rhino.PointAdd(MidPlane(0), vec2))
path2 = Rhino.AddLine(MidPlane(0), Rhino.PointAdd(MidPlane(0), vec1))
midPlane(0) = AveragePoints(aBB)
Dim testPanel, cutter0, cutter1, Path1, path2
' Rhino.AddPoint Rhino.PointAdd(MidPlane(0), Vec1)
If Rhino.IsPointInSurface(aPanels(0), Rhino.PointAdd(MidPlane(0), Vec1)) Then
Cutter1 = Rhino.ExtrudeSurface(CutterBase, path2)
Cutter0 = Rhino.ExtrudeSurface(CutterBase, path1)
Else
Cutter0 = Rhino.ExtrudeSurface(CutterBase, path2)
Cutter1 = Rhino.ExtrudeSurface(CutterBase, path1)
End If
Rhino.DeleteObjects array(Cutterbase, sbaseCrv)
Dim X, Y
X = Rhino.BooleanDifference(aPanels(1), cutter1, True)(0)
Y = Rhino.BooleanDifference(aPanels(0), cutter0, True)(0)
Rhino.DeleteObjects array(path1, path2)
Rhino.DeleteObjects(aExp)
MakeNotch = array(X, Y)
```

End Function

Function SortCurvesByLength(aCrvs)

```
Dim aLen, Bound
Bound = UBound(aCrvs)
ReDim aLen(Ubound(aCrvs))
Dim n
For n = 0 To Bound
aLen(n) = Rhino.CurveLength(aCrvs(n))
Next
Dim aSort: aSort = rhino.SortNumbers(aLen)
Dim result, i, j
i = 0
j = 0
ReDim result(Bound)
For i = 0 To Bound
For j = 0 To bound
If aLen(i) = aSort(j) Then
result(j) = aCrvs(i)
aSort(j) = 0
Exit For
End If
Next
Next
SortCurvesByLength = result
```

End Function

Public Function GetArrayDim(ByVal arr)

Dim i

If IsArray(arr) Then

For i = 1 To 60

On Error Resume Next

Call UBound(arr, i)

If Err.Number <> 0 Then

GetArrayDim = i - 1

Exit Function

End If

Next

GetArrayDim = i

Else

GetArrayDim = Null

End If

End Function

Function IsStringInArray(item, arr, intCase)

'Non case-sensitive= 0, case-sensitive = 1

IsStringInArray = False

If GetArrayDim(arr) = -1 Or IsEmpty(arr) Then

```
Exit Function
End If
Dim sItem
If intCase = 0 Then
For Each sItem In arr
If LCase(sItem) = LCase(Item) Then
IsStringInArray = True
Exit For
End If
Next
Else
For Each sItem In arr
If sItem = Item Then
IsStringInArray = True
Exit For
End If
Next
End If
```

End Function

Function AveragePoints(aPts)

'Finds the average coordinates of an array

âof points.

```
Dim X, Y, Z
Dim i
X = 0
Y = 0
Z = 0
For i=0 To UBound(aPts)
'add all the X values
X = X + aPts(i)(0)
'add all th Y values
Y = Y + aPts(i)(1)
'add all the Z values
Z = Z + apts(i)(2)
Next
'Divide by the number of points to
'get the average for each
'create the output array from the 3 averages
AveragePoints = array(X / (UBound(aPts) + 1), Y / (UBound(aPts) + 1), Z / (UBound(aPts) + 1))
```

End Function