When working on a project, communicating through grid positioning is often necessary. The common approach is to select the two closest grids and check their names. However, my memory isn’t always reliable, so I frequently need to verify a location multiple times before feeling confident. Although some plugins display an axis circle around the outer edge of the workspace, their effectiveness diminishes when there are many dense axis grids.
To improve this, a custom tool was developed through secondary development to quickly identify and locate axis grids. By selecting a point, the tool identifies the two nearest axis grids in different directions, displays a pop-up window, and automatically copies the result to the clipboard.
Currently, the focus is on straight axis grids. Two issues remain unresolved: recognizing curved axis grids and handling multi-segment axis grids. These challenges will be addressed gradually over time.
The following is the core code for this functionality:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
// Select a point
XYZ sel_point = uidoc.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None);
// Get all axis grids
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(doc);
filteredElementCollector.OfClass(typeof(Grid));
// Processing multi-segment and curved grids - to do...
// Filter out all straight axis grids
List lineGrid = new List ();
foreach (Grid g in filteredElementCollector)
{
if ((g.Curve as Line) != null)
lineGrid.Add(g);
}
// Variables to hold the nearest grids
Grid grid_n1 = null;
Grid grid_n2 = null;
double dis1 = double.MaxValue;
double dis2 = double.MaxValue;
// Find the nearest grid to the selected point
foreach (Grid g in lineGrid)
{
if (g.Curve.Distance(sel_point) < dis1)
{
grid_n1 = g;
dis1 = g.Curve.Distance(sel_point);
}
}
// Find the second nearest grid with a different direction
foreach (Grid g in lineGrid)
{
if (!(g.Curve as Line).Direction.IsAlmostEqualTo((grid_n1.Curve as Line).Direction) && g.Curve.Distance(sel_point) < dis2)
{
grid_n2 = g;
dis2 = g.Curve.Distance(sel_point);
}
}
// Format the grid names, placing the grid number at the end first
string name1 = grid_n1.Name;
string name2 = grid_n2.Name;
if (!char.IsNumber(name1.Last()))
{
string name = name1;
name1 = name2;
name2 = name;
}
string inputStr = name1 + " Axis Intersection " + name2 + " Axis";
// DisplayTaskDialog.Show("goodwish", inputStr);
// Copy the result to clipboard
System.Windows.Forms.Clipboard.SetText(inputStr);
return Result.Succeeded;
}













Must log in before commenting!
Sign Up