代码实例:
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Collections.Generic;
namespace RevitAddin4
{
[TransactionAttribute(TransactionMode.Manual)]
public class RevitAddin : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(Wall));
List<ElementId> walIds = new List<ElementId>();
foreach (var wall in collector)
{
walIds.Add(wall.Id);
}
uiDoc.ShowElements(walIds);
return Result.Succeeded;
}
}
}
运行结果: