LocationExtension.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Autodesk.Revit.DB;
  8. namespace FWindSoft.Revit
  9. {
  10. public static class LocationExtension
  11. {
  12. /// <summary>
  13. /// 转换成线
  14. /// </summary>
  15. /// <param name="loc"></param>
  16. /// <returns></returns>
  17. public static Curve ConvertToCurve(this Location loc)
  18. {
  19. if (loc is LocationCurve lc)
  20. {
  21. return lc.Curve;
  22. }
  23. return null;
  24. }
  25. /// <summary>
  26. /// 转换成点
  27. /// </summary>
  28. /// <param name="loc"></param>
  29. /// <returns></returns>
  30. public static XYZ ConvertToPoint(this Location loc)
  31. {
  32. if (loc is LocationPoint lp)
  33. {
  34. return lp.Point;
  35. }
  36. return null;
  37. }
  38. /// <summary>
  39. /// 转换成直线线
  40. /// </summary>
  41. /// <param name="loc"></param>
  42. /// <returns></returns>
  43. public static Line ConvertToLine(this Location loc)
  44. {
  45. if (loc is LocationCurve lc)
  46. {
  47. return lc.Curve as Line;
  48. }
  49. return null;
  50. }
  51. }
  52. }