Pick object(s) from Revit to bring into Rhino using HumanUI

Hi,

I am working on a script that will eventually be a Grasshopper Player plugin with a Humain UI, and it’ll allow the user to select specific objects from the Revit model, in this cenario a railing, and pull it into Grasshopper, and eventually baking that railing into Rhino, then the user will edit the path, etc and then bring it back to Revit as a railing.

I am currently stuck at finding a solution to create a button that picks the objects from Revit, and I’d prefer to find a solution other than running a python script, but I can understand if there’s no other way.

It would be great if the user selects all the objects that they want to be transferred to Rhino first, then they select the button in Human UI. That way the user can ‘select all instances in view’ for example, or just simply select one object.

I’d really appreciate the help.

Here is another way to get the active selection.

The graphical element can be set to the Active Selection via the right click menu.

This is a perfect solution! Thanks a lot :slight_smile:

It’s okay for baking things in Rhino but how to keep the first selection and still move around in Revit while keeping your first selection ?

You might want to query your viewport instead of per selection

I am working on a script that will select elements in Revit in Human UI:

It’s not working yet, any help is welcome:

import clr
clr.AddReference('RhinoInside.Revit')
import RhinoInside
from RhinoInside.Revit import Revit, Convert
clr.ImportExtensions(Convert.Geometry)

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import RevitLinkInstance
from Autodesk.Revit.Exceptions import OperationCanceledException

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *

import datetime
from datetime import datetime

doc = Revit.ActiveDBDocument
uidoc = Revit.ActiveUIDocument

try:
    elemInLinks
except:
    elemInLinks = []

try:
    elemIDs
except:
    elemIDs = []

sel = True  # Ensure selection runs

if sel:
    TaskDialog.Show("Create Selection", "Select elements and press Finish")
    try:
        reflnk = uidoc.Selection.PickObjects(ObjectType.Element, "Select elements")
        elemInLinks = []
        elemIDs = []

        for ref in reflnk:
            try:
                # Attempt to get linked element via LinkedElementId
                lnkinst = doc.GetElement(ref.ElementId)
                if isinstance(lnkinst, RevitLinkInstance):
                    doclnk = lnkinst.GetLinkDocument()
                    elemInLink = doclnk.GetElement(ref.LinkedElementId)
                    if elemInLink and elemInLink.Id.IntegerValue not in elemIDs:
                        elemInLinks.append(elemInLink)
                        elemIDs.append(elemInLink.Id.IntegerValue)
                else:
                    # Local element fallback
                    elem = doc.GetElement(ref.ElementId)
                    if elem and elem.Id.IntegerValue not in elemIDs:
                        elemInLinks.append(elem)
                        elemIDs.append(elem.Id.IntegerValue)
            except:
                # Always fallback to local
                elem = doc.GetElement(ref.ElementId)
                if elem and elem.Id.IntegerValue not in elemIDs:
                    elemInLinks.append(elem)
                    elemIDs.append(elem.Id.IntegerValue)
    except:
        pass

if len(elemInLinks) > 1:
    _Elements = elemInLinks
elif len(elemInLinks) == 1:
    _Elements = elemInLinks[0]
else:
    _Elements = []`

But I get an empty out element, would you know what is wrong ?
type or paste code here