Accessing Revit Context

Using Revit static class you can gain access to the running instance of Revit database and ui, and the open Revit documents.

In Python:

import clr
clr.AddReference("RhinoInside.Revit")
from RhinoInside.Revit import Revit

# application
uiapp = Revit.ActiveUIApplication
dbapp = Revit.ActiveDBApplication

# document
uidoc = Revit.ActiveUIDocument
doc = Revit.ActiveDBDocument

In C#:

using UI = Autodesk.Revit.UI;
using DB = Autodesk.Revit.DB;
using AppServ = Autodesk.Revit.ApplicationServices;

using RhinoInside.Revit;

// application
UI.UIApplication uiapp = Revit.ActiveUIApplication;
AppServ.Application dbapp = Revit.ActiveDBApplication;

// document
UI.UIDocument uidoc = Revit.ActiveUIDocument;
DB.Document doc = Revit.ActiveDBDocument;

Accessing Rhino Context

Using Rhinoceros static class you can gain access to the running instance of Rhino and the open Rhino document.

Unit Conversion

Geometry Conversion

Revit Geometry to Rhino

Use static To* methods on GeometryDecoder to convert (decode) geometry and other relative types from Revit to Rhino. Let’s take a look at how ToBoundingBox can be used to convert a Revit bounding box to equivalent in Rhino.

Snippets below show how to use the converter method as an extension method in Python and C#:

import clr
clr.AddReference("RhinoInside.Revit")
import RhinoInside.Revit.Convert.Geometry
clr.ImportExtensions(RhinoInside.Revit.Convert.Geometry)
# ...
rhino_bbox = revit_bbox.ToBoundingBoxXYZ()
using RhinoInside.Revit.Convert.Geometry;
// ...
var rhinoBBox = revitBBox.ToBoundingBoxXYZ()

Snippets below show how to use the converter method as an static method in Python and C#:

import clr
clr.AddReference("RhinoInside.Revit")
import RhinoInside.Revit.Convert.Geometry.GeometryDecoder as gd
# ...
rhino_bbox = gd.ToBoundingBoxXYZ(revit_bbox)
using RhinoInside.Revit.Convert.Geometry;
// ...
var rhinoBBox = GeometryDecoder.ToBoundingBoxXYZ(revitBBox)

Rhino Geometry to Revit

Use static To* methods on GeometryEncoder to convert (encode) geometry and other relative types from Rhino to Revit. Let’s take a look at how ToBoundingBoxXYZ can be used to convert a Rhino bounding box to equivalent in Revit:

Snippets below show how to use the converter method as an extension method in Python and C#:

import clr
clr.AddReference("RhinoInside.Revit")
import RhinoInside.Revit.Convert.Geometry
clr.ImportExtensions(RhinoInside.Revit.Convert.Geometry)
# ...
revit_bbox = rhino_bbox.ToBoundingBoxXYZ()
using RhinoInside.Revit.Convert.Geometry;
// ...
var revitBBox = rhinoBBox.ToBoundingBoxXYZ()

Snippets below show how to use the converter method as an static method in Python and C#:

import clr
clr.AddReference("RhinoInside.Revit")
import RhinoInside.Revit.Convert.Geometry.GeometryEncoder as ge
# ...
revit_bbox = ge.ToBoundingBoxXYZ(rhino_bbox)
using RhinoInside.Revit.Convert.Geometry;
// ...
var revitBBox = GeometryEncoder.ToBoundingBoxXYZ(rhinoBBox)