ExternalCommand.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:ExternalCommand
  3. * 作者:xulisong
  4. * 创建时间: 2019/3/7 14:50:24
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Autodesk.Revit.DB;
  13. using Autodesk.Revit.UI;
  14. using Autodesk.Revit.Attributes;
  15. namespace FWindSoft.Revit
  16. {
  17. [Transaction(TransactionMode.Manual)]
  18. [Regeneration(RegenerationOption.Manual)]
  19. //[Journaling(JournalingMode.NoCommandData)]
  20. public class ExternalCommand : IExternalCommand, IExternalCommandAvailability
  21. {
  22. /// <summary>
  23. /// 应用级别显示,不用打开项目自动显示
  24. /// </summary>
  25. public bool ApplicationShow { get; set; }
  26. public virtual Result Execute(ExternalCommandData commandData, ref string message,ElementSet elements)
  27. {
  28. RevitCore.InitCore((UIApplication)commandData.Application);
  29. return Result.Succeeded;
  30. }
  31. public virtual bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  32. {
  33. if (ApplicationShow)
  34. {
  35. return true;
  36. }
  37. return applicationData.ActiveUIDocument != null;
  38. }
  39. }
  40. }