Today, I discuss a simple Revit API getting started question from StackOverflow, a new Forge blog and a request for feedback on the keynote manager beta:
Here is a quick 'getting started' Q and A from the StackOverflow question
on the C# Revit API and how to create a simple wall using
Question: I just wanted to create a simple wall using
ExternalCommand, but I cannot figure it out...
I think my problem is here:
var symbolId = document.GetDefaultFamilyTypeId( new ElementId( BuiltInCategory.OST_Walls ) );
When I debug it,
symbolId always equals
Answer: Work through the Revit API getting started material and all will be explained. That will save you and others many further questions and answers.
To address this specific question anyway,
GetDefaultFamilyTypeId presumably does not do what you expect it to for wall elements.
GetDefaultFamilyTypeId method API documentation,
it is used for structural columns, a standard loadable family hosted by individual RFA files.
Walls are built-in system families and behave differently.
GetDefaultFamilyTypeId only works for non-system families.
-1 value represent an undefined element id, equal to
To retrieve an arbitrary (not default) wall type, use a filtered element collector to retrieve all
WallType elements and pick the first one you find.
Here is a code snippet that retrieves all wall types with a filtered element collector and applies .NET LINQ post-processing to that to pick the first one with a specific name, from The Building Coder discussion on creating face wall and mass floor :
WallType wType = new FilteredElementCollector( doc ) .OfClass( typeof( WallType ) ) .Cast<WallType>().FirstOrDefault( q => q.Name == "Generic - 6\" Masonry" );
When you start getting deeper into the use of filtered element collectors, be aware of the significant performance difference between quick and slow filters versus .NET post-processing.
Response: I solved the problem and created many different types of walls already after reading the Revit online help > Revit Developer's Guide > Revit API Developers Guide. Your getting started link is also helpful information for newbies.
A quick welcome to another member of the Forge blogosphere:
Thank you very much, Jürgen, for sharing this information for our German-speaking friends!
It is also useful for any non-German-speaker willing to run a translation tool on it.
Keep up the good work :-)
Who has used the new keynote manager successfully? Does it work fine? Is it intuitive?
Docs are work in progress. Keynote change history with full diff view is next. Open to suggestions...
For more information, please look at the 56-minute presentation of pyRevit 4.6.9 and Keynote Manager Beta:
Thank you very much, Ehsan, for your invaluable work on pyRevit and the new useful keynote manager!