得到类似风管或者墙的系统族的名称,是通过类型的参数得到。 [Transaction(Transa...
过滤条件可以这样累加,小技巧。//墙风管过滤器
class WallDuctSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element e)
{
return (e is Wall) || (e is Duct);
}
public bool AllowReference(Reference r, XYZ p)
{
return true;
}
}
public class cmdTest20110907 : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string messages, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Selection sel = uiDoc.Selection;
Transaction ts = new Transaction(uiDoc.Document, "多类别多选");
ts.Start();
List<Wall> listWall = new List<Wall>();
List<Duct> listDuct = new List<Duct>();
IList<Reference> listRef = sel.PickObjects(ObjectType.Element, new WallDuctSelectionFilter(), "选择墙和风管");
foreach (Reference refObj in listRef)
{
Element el = uiDoc.Document.GetElement(refObj);
if (el is Wall)
{
listWall.Add(el as Wall);
}
else if (el is Duct)
{
listDuct.Add(el as Duct);
}
}
TaskDialog.Show("info", "墙:" + listWall.Count + "\n风管:" + listDuct.Count);
ts.Commit();
return Result.Succeeded;
}
} (*^__^*) 嘻嘻……
页:
[1]