Set Grid Curves in View

Hello people.
Hopefully someone can help me out. I would like to Edit the Grid Curves in the Active view so the start point is at the left of the crop box and the end point at the right of the crop box.

First I collected the cropbox from the Active view.
With those coordinates i created a new curve for a Python input which I found on this thread: Set Level/Grid Curve by Detail Curves in View

But the script gives an error:
Does someone know whats going wrong?
Thanx in advance.

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. _
Traceback (most recent call last):
_ File “”, line 33, in

Exception: The curve is unbound or not coincident with the original one of the datum plane.
Parameter name: curve

setgridscurve

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

Levels = UnwrapElement(IN[0])
Crvs = IN[1]
View = doc.ActiveView
NewCrvs = list()
TransactionManager.Instance.EnsureInTransaction(doc)

for c in Crvs:
	NewCrvs.append(c.ToRevitType())
for l, crv in zip(Levels, NewCrvs):
  	l.SetCurveInView(DatumExtentType.ViewSpecific,View,crv)

TransactionManager.Instance.TransactionTaskDone()

OUT = Levels

Align Grids in View.dyn (24.5 KB)

I got the same result as you. I think this issue has been tackled here:

Did adjusting the off axis grids indeed solve the issue? Im hesitant to modify the grids as we copy monitor them from STRL who owns scope of grids, modifying grids is less than ideal to get this to work.

I haven’t tried the solution in the Building Coder blog, but I think off-axis Grids is not the problem… I’m using correctly aligned grids and I get the same result.
image

Any updated thoughts on this?
Thanks in advance