Cant add RhinoCommon reference

Has anybody else seen this?

I get the same error
It might require rhino inside installed…

I do have rhino.inside installed

:thinking: no idea. I did not get the chance to play around with rhino inside that much

@revitislife Is Rhino.Inside loaded when running this tool and adding a reference?

I just loaded RIR in Revit 2023, and ran this script successfully:

from pyrevit import clr, revit, DB
from pyrevit import script


clr.AddReference('RhinoCommon')
clr.AddReference('RhinoInside.Revit')


from Rhino import Geometry
from RhinoInside.Revit import Revit, Convert

Aha - it wasn’t- is it possible to load and unload rhino.inside through the pyrevit script interface? more so to make the script foolproof

Use this method and global variable (so you can check Rhino version later in your code as well if needed)

RHINO_VERSION = -1

ef ensure_rir():
     """Ensure Rhino.Inside.Revit is loaded"""
     global RHINO_VERSION
     try:
         # this line will cause RhinoCommon to load
         RHINO_VERSION = Rhino.RhinoApp.ExeVersion
     except:
         # lets inform user and end script if RhinoCommon failed to load
         forms.alert("Rhino.Inside.Revit is not available", exitscript=True)
"""

Rhino.Inside.Revit also has an check box in options window to automatically load Rhino when Revit is being loaded.

I updated pyRevit’s RIR Test script to do the same

Is it possible to force-start rhino inside through the pyrevit script - if it’s not already running?

The code that I shared does exactly that. See “ensure_rir” function

1 Like

This is Awesome! Thanks @eirannejad

I tried this solution but I still have the issue with RhinoCommon.Am I missing something? Please let me know