LearnRevitAPI

👉How Selection Really Works in Revit API (Basics for Beginners)

Jul 28, 2025

👉 Master Selection in Revit API

Ready to master Selection with Revit API?🪄

Getting elements is often the first step in creating your tools to test your code, so it makes perfect sense to begin with that.

And luckily for you, it's very simple. Let me show you the basics.

Time to Master Selection!

👉 Revit API Selection for Beginners

Let's begin with documentation.

I know it sounds boring, but coding without docs is like sailing with wind, Not very fun...

The Selection Class which is located in Autodesk.Revit.UI.Selection Namespace. And to use it, we need to get an instance related to our project, so we select the right elements.

We can get it from UIDocument like this:

Once you have Selection, you can use methods to

  • Get user selection

  • Prompt Selection methods

  • Set new selection in Revit's UI

It's easy to use these methods.

Once you have an instance of Selection, we just need to look at the methods to find if we need any arguments or not. And then we just call these methods.

For example here Syntax sections for GetElementIds, PickObjects, SetElementIds from the Docs:

Now let's cover these most popular methods so you know how to work with Selection class.


1. GetElementIds()

Let's begin with the most basic one - GetElementIds

This method returns the ids of the elements that are currently selected within the project.

Here is the code sample:

  • Get Selection instance

  • Get List of ElementIds with GetElementIds

  • Convert ElementIds into Elements

  • Optionally: Filter list of elements

Do you see how simple it is?

2. PickObjects()

Let's look at the second most used method - PickObjects.

This method prompts users to select elements in Revit UI and confirm the selection.

To use it, it needs ObjectType argument and it'll return you a list of References.

💡Don't worry, you can convert Reference to an Element with doc.GetElement(ref) (similar to ElementIds...).

Here is the code sample:

  • Get Selection instance

  • import ObjectType

  • Get List of References from PickObjects

  • Convert References -> Elements

  • Print Results

​P.S.

💡 When you use PickObjects you need to click on Finish button in the top left corner of Revit UI window.

3. PickElementsByRectangle()

Another way we could prompt selection is to use PickElementsByRectangle method.

This one is very simple, doesn't take any arguments and it returns you a list of Elements, so you don't even need to convert anything.

Here is how it works:

  • Get Selection instance

  • Use PickElementsByRectangle

  • That's It!


4. SetElementIds()

Lastly, let me show you how to change user selection in Revit UI with the code. It has a lot of use-cases:

  • Filter Selection

  • Select elements with warnings

  • Select elements that match certain criteria

  • and many more tool ideas...

To use it you need to provide a List[ElementId]() as an argument. Keep in mind that regular python list won't be enough, you'll need to convert it into .NET typed List.

To do that, firstly import the List from System like this:

And then you can use this code snippet to set new selection in Revit UI.

  • Get List of Walls with FEC collector

  • Convert Elements into ElementIds

  • Convert Python List into List[ElementId]()

  • Then use SetElementIds method.

Not so complicated either, right?

P.S.

💡Make sure you provide a list of elements and not a single element when creating List[ElementId](list_here).

That's a very common mistake beginner make with single elements.

Summary

And that's the basics of Selection in Revit API.

It might've sounded hard before we began. But just a few minutes later you learnt the basics and nothing can stop you from using Selection class with these code examples.

Now it's your turn to open a code-editor and try them out.

You can even tweak a few things to create a useful tool to help you with selection for your work inside of Revit. That's how you'll learn the best.

💡 Also, Keep an eye on your inbox.

In the next newsletter you'll learn about advanced selection technique to apply custom filters. This will help you avoid a lot of errors with selection in your code.


P.S.

Meanwhile, if you'd like to learn more about Revit API in an easy way with videos, summaries and even more code examples and real-world application, then make sure to check LearnRevitAPI Course.

Inside you'll get access to my proven roadmap to master Revit API which makes it easy for any beginner to start creating their custom tools from scratch.

Sounds interesting? Then Click Here to Learn More.

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 9500+ people!