/*------------------------------------------------------------------------- * 功能描述:SelectedChangedCommand * 作者:xulisong * 创建时间: 2019/5/31 16:03:04 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.UI.Events; using Autodesk.Revit.DB; using Autodesk.Revit.UI; namespace FWindSoft.Revit { public class SelectedChangedCommand: SingleIdingCommand { private HashSet m_OldIds; protected override void ApplicaionIdling(object sender, IdlingEventArgs e) { if (!Enable) { return; } var application = sender as UIApplication; var ids = application.ActiveUIDocument.Selection.GetElementIds(); //if (ids.Count == 0) //{ // return; //} if (m_OldIds == null || ids.Count != m_OldIds.Count || ids.Any(id => !m_OldIds.Contains(id))) { base.ApplicaionIdling(sender, e); m_OldIds = new HashSet(ids); } } } }