using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
namespace _3_3获取被选中元素
{
[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
//获取当前文件选择集
Selection selection = uidoc.Selection;
ElementSet eles = new ElementSet();
foreach (ElementId elementId in selection.GetElementIds())
{
eles.Insert(uidoc.Document.GetElement(elementId));
}
if (uidoc!=null)
{
foreach (Element selected in eles)
{
Wall wall = selected as Wall;
if (wall!=null)
{
//使用wall
}
}
}
return Result.Succeeded;
}
}
}