Search code examples
c#revit-apirevit

read and export schedules multiple revit file using c# api


I have 150 revit files in a folder. I want to write c# console application that export schedules for each revit files in the folder.

I found some samples in the forums, but I couldnt make it work.

 public void Plot(string[] files)
        {
            ExternalCommandData commandData;
            UIApplication uiApplication = commandData.Application;

            foreach (string file in files)
            {
                Document document = uiApplication.OpenAndActivateDocument(@"C:\solar.rvt").Document;

            }
        }

Solution

  • Yes.

    You cannot make it work like that.

    You cannot drive Revit from outside just like that.

    You can, however, use Idling and External Events for Modeless Access and Driving Revit from Outside.

    However, for the scenario you describe, the easiest solution will be to write a simple external command and launch that from inside Revit to drive the required functionality. Modal, not modeless.

    Implementing an external command is easy and covered in full right at the beginning of the material on getting started with the Revit API.

    Furthermore, you are in luck, because the functionality you describe is implemented by an existing sample described by The Building Coder in The Schedule API and Access to Schedule Data.