Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to build a FilteredElementCollector that will filter down to a number of TitleBlocks we have preloaded into a project. To be clear there are no instances of these elements within the project, they have only been loaded in.
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class Snoop : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> titleFrames = collector
.OfCategory(BuiltInCategory.OST_TitleBlocks)
.OfClass(typeof(Family))
.ToElements();
StringBuilder textMessage = new StringBuilder("Available titleframes: ");
if (titleFrames.Count == 0)
textMessage.AppendLine("Contains no titleframes.");
else
{
foreach (Family titleFrame in titleFrames)
{
textMessage.AppendLine("\nName: " + titleFrame.Name);
}
}
File.WriteAllText(@"C:\Users\user\Documents\Test.txt", textMessage.ToString());
TaskDialog.Show("Revit","Complete");
return Result.Succeeded;
}
}From this code block I recieve the following:
Available titleframes: Contains no titleframes.
I am 100% sure the TitleBlocks are loaded
Am I missing a call?
Or do I need to use a different method to find these elements?
Any help is appreciated.
Thanks
Charlie
Solved! Go to Solution.