Create Horizontal Gridline Alignment

I’m creating horizontal gridline alignment but i’m getting Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 36, in
Exception: The curve is unbound or not coincident with the original one of the datum plane.
Parameter name: curve this errorGridAlignment (Horizontal Grids).dyn (68.9 KB)

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

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

Import RevitAPI

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

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

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

grids = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
crvs = UnwrapElement(IN[2])

curves =
curvesViews =

TransactionManager.Instance.EnsureInTransaction(doc)

for i in range(len(grids),0):
grids[i].SetCurveInView(DatumExtentType.ViewSpecific,view,crvs[i])

TransactionManager.Instance.TransactionTaskDone()
#Assign your outputs to the OUT variable
OUT = grids

Can you confirm that the z dimension of your curve matches with the z dimension of the view. (curve on view plane)?

@habdirad Yes, Z Dimension Doesn’t Match. what should i do to solve this issue ?

You have to get the view plane (possibly a custom node might be available in well known packages) and then use the pull onto plane node to pull your curves onto the view plane. Then feed the new curves to your python solution.

Sir i can’t understand what r u saying exactly? Please give me a example file or code to understand.

OK lets try this. You already have grids in your views, right? why do not we get the Z value from the grids themselves?
Use the grid_curve = grid.GetCurvesInView(DatumExtentType.ViewSpecific,view)[0] to get the grid curve before setting it; with this curve you can retrieve the z value of the viewplane/grid.
grid_endpoint_z = grid_curve.GetEndPoint(0).Z

now you have to adjust your curves to have the Z value. You can get their start point (x,y,z), endpoint (x,y,z) and rebuilt the curve with the grid_endpoint_z.

After rebuilding the curve, you can use your SetCurvesInView and use the curves.

1 Like

@habdirad Thank you sir. I’m getting properly grid but doesn’t give me desired output.