Is it possible to open a revit model via Rhino Inside?

The following code does something like that(?). I am flexing my Python skills with Revit API, excuse me if there is a mistake.

__author__ = "mbgoker"
__version__ = "2021.09.09"

import clr

clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI')

import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
# add extensions methods as well
# this allows calling .ToXXX() convertor methods on Revit objects
clr.ImportExtensions(Convert.Geometry)
from Autodesk.Revit import DB
from Autodesk.Revit import ApplicationServices

# access the active document object
doc = Revit.ActiveDBDocument
app = Revit.ActiveDBApplication
# a few utility methods
def show_warning(msg):
    ghenv.Component.AddRuntimeMessage(RML.Warning, msg)

def show_error(msg):
    ghenv.Component.AddRuntimeMessage(RML.Error, msg)

def show_remark(msg):
    ghenv.Component.AddRuntimeMessage(RML.Remark, msg)

#This is for converting single items to list so we can loop through it.
FilePath = FilePath if isinstance(FilePath, list) else [FilePath]

Document = []

OpenOptions = DB.OpenOptions()

if FilePath:
    for file in FilePath:
        ModelPath = DB.ModelPathUtils.ConvertUserVisiblePathToModelPath(file)
        document = ApplicationServices.Application.OpenDocumentFile(app, ModelPath, OpenOptions)
        Document.append(document)

OpenDocument.gh (8.2 KB)

1 Like