BIM World
A Professional BIM Learning Platform


How to Extract Axis Information in Revit Efficiently

BIM Software Tips: How to Extract Axis Information in Revit

Are you looking to extract information about grids in the current Revit view, such as their names, elevations, and coordinates?

This is a common scenario in Revit programming—locating target objects and retrieving their relevant data.

To find the target objects, you need to utilize Revit’s filtering system. The core class for this purpose is the FilteredElementCollector, which allows you to specify filtering criteria and collect elements that match those conditions.

Once you have these elements, you can access their properties, parameter values, and position information via the Element.Location property.

Below is an example demonstrating how to retrieve such information in Revit:

[Transaction(TransactionMode.Manual)]

public class GetAllGrids : IExternalCommand

{

    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

    {

        UIApplication uiApp = commandData.Application;

        Application app = uiApp.Application;

        UIDocument uiDoc = uiApp.ActiveUIDocument;

        Document doc = uiDoc.Document;

        // Collect all grid elements in the active view

        FilteredElementCollector collector = new FilteredElementCollector(doc, doc.ActiveView.Id);

        collector.OfClass(typeof(Grid));

        string sInfo = string.Empty;

        foreach (Element elem in collector)

        {

            sInfo += “Name = ” + elem.Name + “; “;

            Grid grid = elem as Grid;

            LocationCurve locCurve = grid.Location as LocationCurve;

            Curve cur = locCurve.Curve;

            XYZ ptStart = cur.GetEndPoint(0);

            XYZ ptEnd = cur.GetEndPoint(1);

            // Additional information like coordinates can be processed here

        }

        TaskDialog.Show(“Grid Information”, sInfo);

        return Result.Succeeded;

    }

}

xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » How to Extract Axis Information in Revit Efficiently

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up