Revit commands from python shell

Has anybody found a Python module that can run Revit commands from the Python shell without having to use Dynamo or open Revit before? Our company has a project setup tool that runs off the Python shell and I want to have a way to import our template file, open the file, delete unneeded sheets and then make a PDF of the remaining sheets.

If you don’t open Revit you cannot modify any Revit files.

What I want to do is have a program that runs off Python do the following:

  1. Launch Revit
  2. Open Revit file
  3. Delete unneeded sheets
  4. Print PDF of remaining sheets
  5. Save Revit file
  6. Close Revit file

Want to know if someone has heard of something similar to this available as a Python module?

You might be able to use Dynamo Automation, but this hasn’t been updated for quite some time, so it may not work.

I have done batch processing before, but it required me to open a blank document and process each of the other documents after they had been opened in the background. The basic process was:

  1. Launch Revit (manually)
  2. Create a new document or open a blank document I have created
  3. Launch Dynamo
  4. Run my graph, which will open, modify, and close/save each document from a specified directory
1 Like

AFAIK you can not send a command to Revit until it is open and connected, so I think you would need an application that launches Revit, then launches the connecting code to open the file, delete unwanted things, print and save. Not sure that would save much time over the manually open Revit, run the add-in to background open the file, delete unwanted things, print the rest, save the file and then manually close Revit.

If you’re comfortable writing Python scripts similar to ones that work in RevitPythonShell, then you could use the Revit Batch Processor to do this.

It handles starting the Revit session, opening file, running the script, closing the file and shutting down the session. It handles and reports most warnings, failures and dialog boxes that can appear during the automation. It works for Revit 2015-2020. There’s a beta version that supports Revit 2021 and adds limited support for processing BIM360 files too.