Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Name of WallType from ElementId of GetValidTypes?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
sszakony
1865 Views, 2 Replies

Get Name of WallType from ElementId of GetValidTypes?

Hi, I'm trying to provide my user a list of WallTypes they can choose from. I'm getting a list of the valid ElementIds (TypeId) by using the GetValidTypes() method on the Wall object, but I haven't been able to figure out how to get back to the Name property of the Walltype from the TypeId. Can anyone provide some guidance as to how that might be done?

 

Thanks!

 

Scott S

 

Research Programmer

Center for Research Computing

University of Notre Dame.

2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: sszakony

Dear Scott,

 

I would suggest a different approach:

 

Use a filtered element collector to retrieve all wall type elements from the database.

 

You can cast them to WallType and read their names from the Name property.

 

Here is the untested code for that:

 

  FilteredElementCollector a
    = new FilteredElementCollector( doc )
      .OfClass( typeof( WallType ) );

  foreach( WallType wallType in a )
  {
    Debug.Print( wallType.Name );
  }

 

Actually, this does not even require an explicit cast.

 

This also has the advantage that it does not require some arbitrary wall element as a starting point for calling GetValidTypes on.

 

I am not sure whether it is better than what you are trying right now, though.

 

There is no reason why you could not do it that way as well.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3
sszakony
in reply to: jeremytammik

Jeremy,

 

Not only is that code more elegant, it's much faster than the way I had attempted to do it. Thank you so much for your suggestion.

 

Best regards,

 

Scott

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community