[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class ArgumentUsage : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
//得到选中的对象
Autodesk.Revit.UI.Selection.Selection sel = uiApp.ActiveUIDocument.Selection;
foreach (Element elem in sel.Elements)
{
elements.Insert(elem);//插入错误列表
}
messages = "当前选择集中包含如下对象";
//为了显示错误信息框,需要返回Failed
return Result.Failed;
}
}
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class ElementsWall : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
{
FilteredElementCollector collector =
new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
//筛选出来Wall
ICollection<Element> collection = collector.OfClass(typeof(Wall)).ToElements();
foreach (Element e in collection)
{
elements.Insert(e);
}
return Result.Failed;
}
}