Python in Dynamo vs GHPython - Revit API

Hello,

I am trying to implement some automation with Rhino.Inside.Revit through GHPython to programmatically open a Revit model (Revit 2020). I found a Dynamo Python script at the link below, and it works fine to open a Revit document:

However, when I try to implement this in GHPython, it throws the following error:

Additionally, when I use the CovertUserVisiblePathToModelPath method in GHPython, it returns a FilePath rather than a ModelPath.

Any ideas what the differences are between Dynamo running the script vs GHPython? Any assistance is appreciated!

Thanks,
Joseph

I removed the RevitServices and instead used Autodesk.Revit.ApplicationServices to get past the first error.

Here is what I was talking about re: ConvertUserVisiblePathToModelPath

As I understand it, it needs a string as input and would return a modelPath, but instead it is returning a FilePath.
https://www.revitapidocs.com/2020/0776a818-f032-a332-ac59-962953d8493a.htm

Not sure why. If there is a better way to open a Revit model with RiR programmatically, I’d be all ears!

It looks like opening a Revit model is possible via the Document Grasshopper parameter, but I’m not entirely sure how this could be adapted for what I’m trying to do. See the link below, starting line 87:

Thanks!
Joseph

Hi @jfreund,

Revit.ActiveDBApplication from “RhinoInside.Revit” should work.

1 Like

Thank you, @kike!