Rhino inside + Human UI - Select graphic element in REVIT

Hi.
First of all thanks @andheum for the plugin
Is it possible to create a window with human UI to select a revit geometry?

Just like the “select graphic element” below

I search here and found a C# script for select in rhino viewport, but it is not working in revit obviously

I don’t know enough about Rhino Inside Revit to build this — not sure how that set function works. It would need to follow the pattern of the “pick from rhino” button — if someone who understands RiR better than me wants to write the pick function akin to this one: https://github.com/andrewheumann/humanui/blob/88219c348c93d516ad1715ad8df62ebf6aa7a7d6/HumanUI/HumanUI/Custom%20Types/HUI_RhPickButton.cs I’d be happy to incorporate it.

In order to create the component that Andrew is referring to, you would need to use the Revit API using the pattern of RhPickButton, as Andrew describes – and of course if this is included in HUI, it should only be available in the menus when Revit is the active host. I haven’t built any components for Rhino.Inside yet so I don’t know the specific mechanism, but I assume that it’s part of the SDK based on our usage of Rhino.Inside and existing the Grasshopper plug-ins out there, which only show their functions when they are connected to the available host.

I could see a world where there are a number of supported hosts in HUI, each with the appropriate referenced packages for dev purposes, and they might be separate projects/dll in the repo to allow for better source control independence. The refactor necessary to do this might not be worth the effort, though. Depends how many application-specific components are anticipated in the long run. Intriguing idea either way.

Marc

1 Like

Hmmm I understand.
What I did to solve it was to make an automatic bake for the detail lines (in revit) so they became curves in rhino viewport then I pick it with toggle button.
Thank you guys

Rhino.Inside.Revit provides a set of extension methods on UIDocument that wraps the Revit API selection functionality (due to context changes that are required between Rhino and Revit windows)

See this: https://github.com/mcneel/rhino.inside-revit/blob/master/src/RhinoInside.Revit/External/UI/Selection.cs

2 Likes

Hi,
I would like to prepare HumanUI Rhino.InsidePickButton to have possibility to select Revit elements and also selection filters from HumanUI interface. I have duplicated HUI_RhPickButton and called it HUI_RhInsidePickButton and tried to change the code but despite Rhino.Inside nuget installation the namespace RhinoInside.Revit.External.UI.Selection to use PickObject method is not available.

I would like to prepare left click Human UI button menu the same like at Rhino.Inside to get opportunity to Select One Object, Multiple Object and also selectionFilters.

Unfortunately I have only basic knowledge of C# with Rhino.Inside API so any help and suggestion are welcome.

I’ve tried to find on Rhino.Inside Github Repository code responsible for Graphical Element to better understand the construction left click button and access menu. Unfortunately I couldn’t find it.

I really appreciate to sending the link to that part of repository.

I’m sending link to Github repository where I’m working on this HumanUI button. I will be grateful for every help.

Hello,

I see that Github link you provided is marked as obsolete.
Also, link from this post is not working

Is there something new in that topic? Has anyone sucessfuly made Human UI to click-select graphical elements in Revit?

I think there might be an answer on that topic here https://discourse.mcneel.com/t/rhino-inside-revit-crashing-with-human-ui-if-window-has-not-been-opened/147690/12

Hello everyone, I have a couple of graphs that utilize this functionality primarily to gather elements from linked models. I hope they can be an inspiration or help. I’m working with linked models specifically, but it should be possible to grab elements in the model by changing the selection filter.

select elements gif

here is the python code to make it possible. This is not all my work. I must give credit to Alban de Chasteigner and his package Genius Loci for Dynamo.

Below is the python code to make this possible.

#Wade Vollink 2023, inspired by code from Alban de Chasteigner 2021, @geniusloci_bim

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 = []


if sel:
    TaskDialog.Show("Create Selection", "Select the linked elements and press Finish")
    try:
        reflnk = uidoc.Selection.PickObjects(ObjectType.LinkedElement, "Select linked elements")
        elemInLinks=[]
        elemIDs = []
        for ref in reflnk :
            lnkinst=doc.GetElement(ref)
            doclnk =  lnkinst.GetLinkDocument()
            elemInLink = doclnk.GetElement(ref.LinkedElementId)
            try:
                elemIDs.index(elemInLink.Id.IntegerValue)
            except:
                elemInLinks.append(elemInLink)
                elemIDs.append(elemInLink.Id.IntegerValue)
    except:
        pass

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

I’ve also figured out a way to integrate this into human ui. The trick I found is that the true button for human ui causes the canvas to refresh twice and which ultimately creates a bottleneck for the selection to happen in Revit. To get around this use a true only button. It will cause the node to recompute only once.

select elements gif2

1 Like