ElementTypeExtension.cs 876 B

123456789101112131415161718192021222324252627282930
  1. using Autodesk.Revit.DB;
  2. using FWindSoft.Revit.Common;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace FWindSoft.Revit
  9. {
  10. public static class ElementTypeExtension
  11. {
  12. /// <summary>
  13. /// 复制增加图元类型
  14. /// </summary>
  15. /// <typeparam name="T"></typeparam>
  16. /// <param name="elementType"></param>
  17. /// <param name="strName"></param>
  18. /// <returns></returns>
  19. public static T DuplicateT<T>(this ElementType elementType, string strName) where T : ElementType
  20. {
  21. if (strName.Length > 128)
  22. {
  23. strName = strName.Substring(0, 127);
  24. }
  25. strName = RevitTools.RemoveForbiddenChars(strName);
  26. return elementType.Duplicate(strName) as T;
  27. }
  28. }
  29. }