Selection Region as Polygon

Does anyone knows how to create a selection region like in that video?

Thank you!

1 Like

I don’t believe Revit API naturally does this. My guess is they use a while loop and yield a bunch of picked points to form a polygon, extrude it, then solid intersect it with element bounding boxes or something along those lines.

You can prompt point selection using this class/method:

Just tried it out and it works, put this in a Python node with no inputs and one output, then run and pick your points and hit escape to finish and send them on. These can them form a solid polygon, and you could also convex hull them if you’re worried about user point order. I’m guessing if you use C# you can also render the points/edges as you go versus Dynamo where you draw blindly. I guess you could make annotation lines temporarily using transactions at each step of the way?

# Boilerplate text
import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

# Inputs and variables
uisel  = uidoc.Selection
msg    = 'Pick points, then hit escape to continue.'
ptList = []

keepPicking = True

TaskDialog.Show("Pick polygon", msg)

while keepPicking:
	try:
		xyz = uisel.PickPoint(msg)
		ptList.append(xyz.ToPoint())
	except:
		keepPicking = False

OUT = ptList
2 Likes

Thank you very much for your reply @GavinCrump! For me would be nice to know, how to demonstrate that polygon while user keep clicking. I saw that mostly on websites when you are looking for a flat :slight_smile: