Hi,
I am working on a project where i need to the get the current selected elements in a floorView , with dynamo.
I’m using Revit 2023
Does anyone knows how can i do this, do i have to install a pacakge?
If yes, what package?
Thanks
Hi,
I am working on a project where i need to the get the current selected elements in a floorView , with dynamo.
I’m using Revit 2023
Does anyone knows how can i do this, do i have to install a pacakge?
If yes, what package?
Thanks
Hello @miguel.bc.silvestre and welcome to the forum…you could try this one here from spring…
This should work in Revit 2023 using either of the Python engines (from Crumple - Revit.Selection). Probably similar to Spring nodes implementation.
# Made by Gavin Crump
# Free for use
# BIM Guru, www.bimguru.com.au
# Boilerplate text
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
# Get selection
selected = uidoc.Selection.GetElementIds()
# Return elements
result = []
for id in selected:
e = doc.GetElement(id).ToDSType(True)
result.append(e)
# Preparing output to Dynamo
OUT = result
Looks like a slightly more comprehensive version that either returns a single object or a list, so might be a bit more advantageous than mine in the event the user selects one object and wants a flat list structure.
yes…but both works great
thank, for your answers , where very helpful
Hi @sovitek ,
Sorry, I know this thread is a few months old. But I am just wondering if, is it possible to make this script to be kind of a one shot script? What I mean is, every time we hit the Run button it will reset or clear the current list of elements before getting another set of selected element in the model. No need to set the boolean node from True to False and vice versa. tia
Not within a Dynamo script between runs. The node will only re-run in the same session if its inputs have changed, that’s pretty much the purpose of that boolean input.
You can do this a few different ways.