RhinoScript Offset Closed curve

Hello, everyone

I’m trying to develop a script to offset a closed curve certain distance, I’m using this code but it does not work. It may be possible to get some help with it?

Option Explicit
 
 Function RhinoOffsetClosedPlanarCurve(ByVal strCurve, ByVal dblDistance, ByVal blnOutside)
 
   ' Local variables
   Dim arrPlane, arrOldPlane, strView, arrBox, arrPoint
 
   ' Default return value
   RhinoOffsetClosedPlanarCurve = Null
 
   ' Quick parameter validation
   If (VarType(strCurve) <> vbString) Then Exit Function
   If Not IsNumeric(dblDistance) Then Exit Function
   If (VarType(blnOutside) <> vbBoolean) Then Exit Function
 
   ' Curve validation
   If (Rhino.IsCurve(strCurve) = False) Then Exit Function
   If (Rhino.IsCurveClosed(strCurve) = False) Then Exit Function
   arrPlane = Rhino.CurvePlane(strCurve)
   If Not IsArray(arrPlane) Then Exit Function
 
   ' Calculate plane-based bounding box
   strView = Rhino.CurrentView()
   arrOldPlane = Rhino.ViewCPlane(strView, arrPlane)
   arrBox = Rhino.BoundingBox(strCurve, strView)
   Call Rhino.ViewCPlane(strView, arrOldPlane)
 
   ' Offset point so its outside of bounding box
   arrPoint = Rhino.PointAdd(arrBox(0), Rhino.VectorCreate(arrBox(0), arrBox(2)))
 
   ' Offset the curve 
   If (blnOutside = False) Then dblDistance = -dblDistance
   RhinoOffsetClosedPlanarCurve = Rhino.OffsetCurve(strCurve, arrPoint, dblDistance, arrPlane(3))
 
 End Function