Thought this might be useful for anyone looking to make calls to Rhino.Inside or RhinoCommon in either custom Python nodes or custom C# nodes, I’ve added two example boilerplates to get started. Note that before making calls to the Rhino APIs, Rhino.Inside.Revit must be installed and running in the background otherwise the Rhino libraries can’t be accessed:
Python
import clr
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import sys
import os
roamingFolder = os.getenv('APPDATA')
rhinoInsidePath = roamingFolder + r'\Autodesk\Revit\Addins\2019\RhinoInside.Revit'
rhinoCommonPath = r'C:\Program Files\Rhino 7 WIP\System'
sys.path.append(rhinoInsidePath)
sys.path.append(rhinoCommonPath)
clr.AddReference("RhinoInside.Revit")
import RhinoInside
from RhinoInside.Revit.Convert.Geometry import *
clr.AddReference("RhinoCommon")
import Rhino
from Rhino.Geometry import *
doc = DocumentManager.Instance.CurrentDBDocument
#Uncomment the line below to enable the first input
#t = UnwrapElement(IN[0])
# "Start" the transaction
#TransactionManager.Instance.EnsureInTransaction(doc)
# "End" the transaction
#TransactionManager.Instance.TransactionTaskDone()
#Uncomment the line below to output an object
#OUT = t
C# (zero touch import)
Reference the following libraries to do pretty much anything you need:
using Autodesk.Revit.DB;
using Revit.GeometryConversion;
using RevitServices.Persistence;
using Rhino.Geometry;
using RhinoInside.Revit.Convert.Geometry;
namespace DynamoNodes.RhinoInside
{
public class RhinoInsideNode
{
public RhinoInsideNode(bool refresh)
{
var doc = DocumentManager.Instance.CurrentDBDocument;
// Write your code here.
}
}
}