[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;
    }
}
过滤出来Wall
[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;
    }
}

相关文章:

  • 2021-09-22
  • 2021-07-23
  • 2021-12-06
  • 2021-12-15
  • 2021-07-11
  • 2022-03-09
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2021-07-27
  • 2021-03-31
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-12-26
相关资源
相似解决方案