1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /*-------------------------------------------------------------------------
- * 功能描述: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<ElementId> 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<ElementId>(ids);
- }
- }
- }
- }
|