When working with Revit for drawing, annotating the grid is an essential task. Below are some insights and development tips for grid dimension annotation:
Grid Dimension Annotation:
First, obtain the reference for the dimension annotation and add it to a reference collection. The key code snippet is shown below:
ReferenceArray array = new ReferenceArray();
array.Append(new Reference(grid));
Next, here is a method to determine the position for dimension annotation by calculating a point on the grid’s curve at a specified distance from the start point:
public static XYZ getStartPoint(Line line, double length)
{
XYZ start = line.GetEndPoint(0);
XYZ dir = line.Direction;
XYZ tempone = start + length * dir;
return tempone;
}
The method for calculating a point at a certain distance from the end point is similar:
public static XYZ getEndPoint(Line line, double length)
{
XYZ end = line.GetEndPoint(1);
XYZ dir = line.Direction;
XYZ temptwo = end - length * dir;
return temptwo;
}
After obtaining these points on the grids, connect the points of adjacent grids to create a new line. Then, use the new dimension annotation method to apply the grid dimension annotation, as demonstrated below:
Transaction tran = new Transaction(doc);
tran.Start("Grid Dimension Annotation");
Dimension nowDim = doc.Create.NewDimension(doc.ActiveView, nowLine, arrayTwo);
tran.Commit();
Here, nowLine is the new Line constructed from the points taken from adjacent grids, and arrayTwo represents the collection of grid references.
That concludes the sharing. If you have any questions or better development ideas, please feel free to leave a message below.













Must log in before commenting!
Sign Up