ellipse.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Created: 25.03.2011
  2. # Copyright (c) 2011-2018, Manfred Moitzi
  3. # License: MIT License
  4. from .graphics import ExtendedTags, DXFAttr, DefSubclass, DXFAttributes, XType
  5. from .graphics import none_subclass, entity_subclass, ModernGraphicEntity
  6. _ELLIPSE_TPL = """0
  7. ELLIPSE
  8. 5
  9. 0
  10. 330
  11. 0
  12. 100
  13. AcDbEntity
  14. 8
  15. 0
  16. 100
  17. AcDbEllipse
  18. 10
  19. 0.0
  20. 20
  21. 0.0
  22. 30
  23. 0.0
  24. 11
  25. 1.0
  26. 21
  27. 0.0
  28. 31
  29. 0.0
  30. 40
  31. 1.0
  32. 41
  33. 0.0
  34. 42
  35. 6.283185307179586
  36. """
  37. ellipse_subclass = DefSubclass('AcDbEllipse', {
  38. 'center': DXFAttr(10, xtype=XType.any_point),
  39. 'major_axis': DXFAttr(11, xtype=XType.any_point), # relative to the center
  40. 'extrusion': DXFAttr(210, xtype=XType.point3d, default=(0.0, 0.0, 1.0)),
  41. 'ratio': DXFAttr(40),
  42. 'start_param': DXFAttr(41), # this value is 0.0 for a full ellipse
  43. 'end_param': DXFAttr(42), # this value is 2*pi for a full ellipse
  44. })
  45. class Ellipse(ModernGraphicEntity):
  46. __slots__ = ()
  47. TEMPLATE = ExtendedTags.from_text(_ELLIPSE_TPL)
  48. DXFATTRIBS = DXFAttributes(none_subclass, entity_subclass, ellipse_subclass)