I’m currently working on automating some tasks using PyRevit CLI and the Revit API. My goal is to run Python scripts without actually opening the Revit GUI. Specifically, I’ve written a simple script to open an IFC file and save it as an RVT file. Here’s the script:
import clr
import math
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.DB.Analysis import *
app = __revit__.Application
ifc_doc = app.OpenIFCDocument('Room.ifc')
print("Open")
save_options = SaveAsOptions()
save_options.OverwriteExistingFile = True
ifc_doc.SaveAs('output_room.rvt', save_options)
print("Saved")
When I run this script with the command pyrevit run script.py "revitproject.rvt", Revit opens and closes again, displaying information about the execution ID, product, clone, engine, script, working directory, journal file, manifest file, and log file.
I’m looking for guidance on how to correctly use the PyRevit CLI to achieve my goal without the Revit GUI popping up. Are there any specific resources, documentation, or tutorials that could help with this?
You mean without Revit opening at all? As far as I know you will always have the Revit window open unless you are using one of the APIs for cloud hosted models like Forge and whatever they calling the other ones now.
Hi @Jean-Marc, I have a question. For example I have a script to set parameter values for some elements. If I use this way to run it, will the revit model be saved after running?