先运行程序,后单选模型
Reference blend2 = uiDoc.Selection.PickObject(ObjectType.Element, "blend");
Blend blend = doc.GetElement(blend2) as Blend;
先运行程序,后多选模型
List<Reference> blend3 = uiDoc.Selection.PickObjects(ObjectType.Element, "blend").ToList();
List<Element> blends = new List<Element>();
foreach (var item in blend3)
{
Blend blend6= doc.GetElement(item) as Blend;
blends.Add(blend6);
}
先多选模型,后运行程序。
//取到当前文档的选择集。
Selection selection = uidoc.Selection;
//获取所有选择项(Element),从ElementId转成Element
List<Element> collection = selection.GetElementIds().Select(x => doc.GetElement(x) as Element).ToList();