To access the System Families in a Revit Template file, we can use the ElementType to list system family types (for example Wall types, floor types, etc).
The following code snippet, creates a list of all the ElementTypes including the system family types. The code create a log file with the type name as well as the family name (using the Built-In parameter) and this code can be run this on the template file to get the information desired.
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
// Get the application and document
Application app = commandData.Application.Application;
Document activeDoc =
commandData.Application.ActiveUIDocument.Document;
var familyTypeCollector1 =
new FilteredElementCollector(activeDoc);
familyTypeCollector1.OfClass(typeof(ElementType));
IList<Element> famTypes =
familyTypeCollector1.ToElements();
System.IO.StreamWriter writer =
new System.IO.StreamWriter(
"C:\\Temp\\ElementTypes.txt");
foreach (Element ele in famTypes)
{
ElementType type = ele as ElementType;
if (null != type)
{
writer.WriteLine("——————————-");
writer.WriteLine(type.Name + ": "
+ type.get_Parameter(
BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM)
.AsString());
}
}
writer.Close();
return Result.Succeeded;
}
}
Using this code with the Column template, creates the output text file listing the symbol and the family names contained in the template, as shown below:


Leave a Reply