HELP! Pick instance & delete category C#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm still a beginner with C# & Revit API. I would like to have the user start the Macro and have it ask "Please select a Family". I need the Macro to find the Category and delete all of them found in the entire project.
I am stuck on the last entry (see bold) I can't figure out how to have the element selected find the Built-in-Category and delete them all.
namespace DeleteCategory
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class DeleteCategory : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Get application and document objects
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
//Define a Reference object to accept the pick result
Reference pickedRef = null;
//Pick a Family
Selection sel = uiApp.ActiveUIDocument.Selection;
pickedRef = sel.PickObject(ObjectType.Element, "Please select a Family");
Family fam = Element as FamilyInstance;