How do you open a new Revit document from Python?

How do you open a new Revit document from Python?

Here is what I have. I am not sure how to place the arguments for Application.NewProjectDocument() method. It is asking for 2 arguments.

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.ApplicationServices import *

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

app = Application.NewProjectDocument(Imperial)

#Assign your output to the OUT variable.
OUT = 0

I am having this same issue. The API documentation says the method might take a String for the name of a Template file. Try adding the argument “Construction Template” or something?

When I run the code, I get the message that Imperial is not defined. How did you define the variable “Imperial”?

NameError: name ‘Imperial’ is not defined

For creating using a UnitSystem (imperial/metric), try UnitSystem.Imperial

Thank you jbo.

Here is some code that I also got working for my purposes, where “template” is the file path to a template file (such as “Construction Template”).

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

template = IN[0]

new_proj = app.NewProjectDocument(template)

i need to start a project from a template as well, used your code but nothing seems to happen…
Something happens at the background, but no document is opened