Import Revit nodes in python

Hello there,

is there any way of importing the nodes of Rhino.Inside within my python script? I want to import particulary AddWall.ByCurve and AddFamilyInstance.ByLocation.

Thanks in advance

https://www.rhino3d.com/inside/revit/beta/guides/rir-ghpython

1 Like


thanks for the link you sent, it is an useful link to understand to use transactions and import the Revit API but i was trying to import the RhinoInside Revit grasshopper nodes, that you see in red in the picture. Is there a way to import them? maybe to copy them into a c# node within the grasshopper script? (https://github.com/mcneel/rhino.inside-revit/tree/master/src/RhinoInside.Revit.GH/Components)
For instance we can see here that the grasshopper nodes are imported(https://developer.rhino3d.com/guides/rhinopython/ghpython-call-components/). Well I am looking for a similar workflow but for the Revit nodes.
thanks in advance!

heres an example of NodeInCode

import ghpythonlib.components as gh
gh.PLUGIN_NAMESPACE.COMPONENTNAME()
# An example with the Weaver Bird plugin
outputPolygons = gh.WeaverBird.WeaverbirdsFacePolylines(inputMesh)
1 Like

image
I needed to comment the line "gh.PLUGIN_NAMESPACE.COMPONENTNAME()
" cause it throws an error, “module” object hast not attribute “PLUGIN_NAMESPACE”:
Nevertheless I can call the gh.RhinoInside nodes, the problem is that it doesnt generate the walls but it doesnt have any error either, so I dont know anymore what is wrong actually.
Thanks in advance

This is way out of my arena.

Doesn’t revit require you to open a transaction?

https://www.rhino3d.com/inside/revit/beta/guides/rir-ghpython#handling-transactions

Hello Rickson,
the transaction is within the definition already in this case within the gh.RhinoInside.AddWallByCurve(),
I tried though to open a transaction and create the wall but it threw an error.

Filed an issue for this

Hi all! I’m having some trouble with accessing the RhinoInside Revit components.

I have imported the components module(s) and am attempting to call a RhinoInside Revit component but I am getting errors that no RhinoInside attribute exists. I’ve tried both the ghpythonlib and Rhino.NodeInCode methods. What am I missing here?

Software info:

Revit 2019.2.6
image

here is what I am trying to achieve:

import rhinoscriptsyntax as rs
import clr
clr.AddReference('System.Core')
clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI')

import System
import Rhino
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML

# bring in the node-in-code handle
from Rhino.NodeInCode import Components
import ghpythonlib.components as ghc

# Revit API
from Autodesk.Revit import DB

from RhinoInside.Revit import Revit

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)

def get_category(category_name):
    doc = Revit.ActiveDBDocument
    for cat in doc.Settings.Categories:
        if cat.Name == category_name:
            return cat

walls = get_category("Walls")

comp = Components.FindComponent("RhinoInside_QueryTypes")
if not comp:
    a = "error"
else:
    a = comp

#b = Components.NodeInCodeFunctions.RhinoInside_QueryTypes(doc, "System", walls)

#ghc.RhinoInsideRevit.QueryTypes(doc, "System", walls)

Runtime error (MissingMemberException): ‘NodeInCodeTable’ object has no attribute ‘RhinoInside_QueryTypes’


Runtime error (MissingMemberException): ‘module’ object has no attribute ‘RhinoInsideRevit’

Gave it a look and having the same problem where RhinoInside components are not available in the list of NodeInCode components to be used, other tools components are showing like Elefront, lunchbox etc… but not ones from RiR… so not sure what’s missing

1 Like

Hey again,

So I found a way around getting the components to be found which I assume is not the intended solution…

What I did is go inside Revit Addin files and copied the “RhinoInside.Revit.GH.gha” file to the Grasshopper special folders (Components folder)

Now when I reopened Revit and then Rhino i was prompted there were duplicate components that were being loaded and Skipped All, now when I ran the grasshopper NodeInCode list of components the RiR nodes were available for use

So, that’s a temporary solution I assume until maybe someone can tell us the reason / guide us to a better solution.

2 Likes

Hello Mohamed,

I wanted to let you know that your solution was fantastic! I’ve been searching for a fix for quite some time, trying various methods with Revit 2024 and Rhino 8, but nothing worked until now. Your solution worked perfectly. Thank you so much for sharing it.

Best regards,
Tran