FanSystemDrawer.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import math
  2. import ezdxf
  3. from ezdxf import math as mt
  4. from core import rotate_point_around_another
  5. class FanSystemDrawer:
  6. def __init__(self, msp, layer, gap, center, route):
  7. self.msp = msp
  8. self.gap = gap
  9. self.center = center
  10. self.route = route
  11. self.layer = layer
  12. def draw_fan_system(self):
  13. rad = self.gap / 2
  14. carc = mt.arc.ConstructionArc()
  15. # 初始化扇形起始和结束点
  16. fan_a_start = (self.center[0], self.center[1] + rad)
  17. fan_b_start = (self.center[0] - rad / 2, self.center[1] + rad / 2)
  18. # 绘制中心圆
  19. self.msp.add_circle(self.center, rad,dxfattribs={"layer": f"图层{self.layer}"})
  20. # 绘制每个扇形
  21. for i in range(3):
  22. fan_a = rotate_point_around_another(fan_a_start, self.center, self.route + i * (2 / 3) * math.pi)
  23. fan_b = rotate_point_around_another(fan_b_start, self.center, self.route + i * (2 / 3) * math.pi)
  24. fan_carc_3p = carc.from_3p(start_point=fan_a, def_point=fan_b, end_point=self.center)
  25. self.msp.add_arc(center=fan_carc_3p.center, radius=fan_carc_3p.radius,
  26. start_angle=fan_carc_3p.start_angle, end_angle=fan_carc_3p.end_angle,dxfattribs={"layer": f"图层{self.layer}"})
  27. # 绘制中心到扇形起点的线段
  28. self.msp.add_line(fan_a, self.center,dxfattribs={"layer": f"图层{self.layer}"})