Using Rhino Curves in Python RIR

Hi guys,

How can I use Rhino curves in RIR Python environment? I want to create something out of Rhino curves using Revit API. How can I convert Rhino curves to Revit compatible curves through RhinoInside.Revit library?

An example would be great. Thanks.

We need to create some documentation for this, but here a sample. (13.3 KB)

Please remember to adjust Type Hint on inputs from the context menu.

import clr

import RhinoInside

if _point is not None:
    point_ = _point.ToXYZ()

if _curve is not None:
    curve_ = _curve.ToCurve()

if _box is not None:
    box_ = _box.ToBoundingBoxXYZ()

if _brep is not None:
    solid_ = _brep.ToSolid()

Yes, documentation is definitely needed. I have tried ToCurve() method but got the following error.

  1. Solution exception:‘NoneType’ object has no attribute ‘ToCurve’

Any idea why?

import clr

from System import Enum
from System.Collections.Generic import List

import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
from Autodesk.Revit import DB


# access the active document object
doc = Revit.ActiveDBDocument

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)

curves = List[DB.Curve]()

clc = DB.CurveLoop.Create(curves)

#Create and Start Transaction
t = DB.Transaction(doc, "Create Ceiling")
    ceiling = DB.Ceiling.Create(doc, curves, Type.Id, Level.Id)
except Exception as txn_err:

I am trying to create a ceiling from a given single curve outline. I am quite new in Revit API. If I have any noob mistakes, just forgive :slight_smile:

I got the same error from the definition you shared.

where is the Curve in curves.Add(Curve.ToCurve()) object coming from?


It is the curve input in the Python node. I got the same error in the definition that kike shared though.

Hi @mucahitbgoker,

I edited the previous post to check if the user has something plugged in the component.

Now it should not show any error even if you don’t connect anything.

Hi @kike,

I get the following error.

  1. Solution exception:Failed to convert non G1 continuous curve.

I connected a simple rectangle as an input in your definition.

When I tried it with my script, I get this error too:

  1. Solution exception:Failed to convert non G1 continuous curve.

I see,

You are trying to convert a boundary to create the ceiling.

Since Revit curves should be C2 you can not convert a curve with kinks to a Revit Curve.

On these cases you should use ToCurveLoop or ToCurveArray depending on where you like to use the result.

Celing.Create takes a CurveLoop.

So you need ToCurveLoop here to convert each loop.

Thanks @kike. Now I can use curves to create ceiling. Can I achieve element binding in Python component though? Whenever a change happens in the Grasshopper environment, it recreates a ceiling.

Right now there is no API for Element Tracking.
We want to be sure this implementation works for the users before release it to a wider audience.

But will be available on an upcoming release.

1 Like

Okidoki @kike. Thank you!:vulcan_salute:

About documentation you may use the source code itself.

Here you have conversion from Rhino to Revit.

And here from Revit to Rhino.

Searching “public static” should give you an idea of what is available.

@kike-asuni Any example for c# that you can share please?