LearnRevitAPI

Jul 19, 2023

Get Default Element Type

There are times during development when we need to get random Types to test a snippet. I used to use FilteredElementCollector but there is an easier method available to get Default Type.

💡 Let's learn how to get Default Element Types!

👀 Available Methods

Whenever you create elements in Revit UI, you always have a default type for each category, usually it's the last used. 

And there are 2 methods in Revit API that can give us default types:

.GetDefaultElementTypeId()

.GetDefaultFamilyTypeId()

These 2 methods do similar thing - They give you an ElementId of Default Type.

But one is used on native Revit Elements like Walls,Floors... and the other is used for Loaded Families like Windows,Doors... 

👀 So let's have a look at examples on how to use both of them!

1️⃣ .GetDefaultElementTypeId()

This method is very straight-forward. It takes a single argument - ElementTypeGroup, which is an enumeration. 

Enumeration is a data type in programming that allows you to define a set of named values. 

It provides a way to group related values together under a single type, making your code more organized and readable.

So you just have to choose the right option like ElementTypeGroup.WallType for example, and you will get Element Id of your Default Wall Type.

2️⃣ .GetDefaultFamilyTypeId()

Unlike .GetDefaultElementTypeId this method takes familyCategoryId as an argument. It simply means that we need ElementId of a category which type we are trying to get for example: ElementId(BuiltInCategory.OST_Windows)

So it's quite simple once you see an example of how to use it.
👇 Have a look below.

I hope this has made it clear for you on how to get default types with Revit API and you are going to use it in your scripts. 

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 7200+ people!

Last Chance To Claim LIFETIME ACCESS. [~30 Seats left]