1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import math
- import ezdxf
- import core
- class FanLocalDrawer:
- def __init__(self, msp, layer, gap, center, route):
- self.msp = msp
- self.gap = gap
- self.center = center
- self.route = route
- self.layer = layer
- # a2
- # ___a3
- # |
- # a1
- def draw_fan_local(self):
- rad = 0.5 * self.gap
- self.msp.add_circle(center=self.center, radius=rad, dxfattribs={"layer": f"图层{self.layer}"})
- a1 = self.center[0], self.center[1] + rad
- a2 = self.center[0], self.center[1] + rad * 3 / 2
- a3 = self.center[0] + rad * 1 / 2, self.center[1] + rad * 3 / 2
- a1 = core.rotate_point_around_another(a1, self.center, self.route)
- a2 = core.rotate_point_around_another(a2, self.center, self.route)
- a3 = core.rotate_point_around_another(a3, self.center, self.route)
- self.msp.add_line(a1, a2, dxfattribs={"layer": f"图层{self.layer}"})
- self.msp.add_line(a2, a3, dxfattribs={"layer": f"图层{self.layer}"})
- a4 = core.rotate_point_around_another(a1, self.center, -2/3*math.pi)
- a5 = core.rotate_point_around_another(a2, self.center, -2/3*math.pi)
- a6 = core.rotate_point_around_another(a3, self.center, -2/3*math.pi)
- self.msp.add_line(a4, a5, dxfattribs={"layer": f"图层{self.layer}"})
- self.msp.add_line(a5, a6, dxfattribs={"layer": f"图层{self.layer}"})
- a7 = core.rotate_point_around_another(a1, self.center, 2/3*math.pi)
- a8 = core.rotate_point_around_another(a2, self.center, 2/3*math.pi)
- a9 = core.rotate_point_around_another(a3, self.center, 2/3*math.pi)
- self.msp.add_line(a7, a8, dxfattribs={"layer": f"图层{self.layer}"})
- self.msp.add_line(a8, a9, dxfattribs={"layer": f"图层{self.layer}"})
- doc = ezdxf.new("R2013")
- msp = doc.modelspace()
- fl = FanLocalDrawer(msp,1,5,(90,80),1.114514)
- fl.draw_fan_local()
- doc.saveas("123.dxf")
|