trace.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Created: 25.03.2011
  2. # Copyright (c) 2011-2018, Manfred Moitzi
  3. # License: MIT License
  4. from typing import cast
  5. from ezdxf.lldxf.const import VERTEXNAMES
  6. from .graphics import GraphicEntity, ExtendedTags, make_attribs, DXFAttr, XType
  7. class QuadrilateralMixin:
  8. __slots__ = ()
  9. def __getitem__(self, num):
  10. return cast(GraphicEntity, self).get_dxf_attrib(VERTEXNAMES[num])
  11. def __setitem__(self, num, value):
  12. return cast(GraphicEntity, self).set_dxf_attrib(VERTEXNAMES[num], value)
  13. _TRACE_TPL = """0
  14. TRACE
  15. 5
  16. 0
  17. 8
  18. 0
  19. 10
  20. 0.0
  21. 20
  22. 0.0
  23. 30
  24. 0.0
  25. 11
  26. 0.0
  27. 21
  28. 0.0
  29. 31
  30. 0.0
  31. 12
  32. 0.0
  33. 22
  34. 0.0
  35. 32
  36. 0.0
  37. 13
  38. 0.0
  39. 23
  40. 0.0
  41. 33
  42. 0.0
  43. """
  44. class Trace(GraphicEntity, QuadrilateralMixin):
  45. __slots__ = ()
  46. TEMPLATE = ExtendedTags.from_text(_TRACE_TPL)
  47. DXFATTRIBS = make_attribs({
  48. 'vtx0': DXFAttr(10, xtype=XType.any_point),
  49. 'vtx1': DXFAttr(11, xtype=XType.any_point),
  50. 'vtx2': DXFAttr(12, xtype=XType.any_point),
  51. 'vtx3': DXFAttr(13, xtype=XType.any_point),
  52. })
  53. class Solid(Trace):
  54. __slots__ = ()
  55. TEMPLATE = ExtendedTags.from_text(_TRACE_TPL.replace('TRACE', 'SOLID'))
  56. class Face(Trace):
  57. __slots__ = ()
  58. TEMPLATE = ExtendedTags.from_text(_TRACE_TPL.replace('TRACE', '3DFACE'))
  59. DXFATTRIBS = make_attribs({
  60. 'vtx0': DXFAttr(10, xtype=XType.point3d),
  61. 'vtx1': DXFAttr(11, xtype=XType.point3d),
  62. 'vtx2': DXFAttr(12, xtype=XType.point3d),
  63. 'vtx3': DXFAttr(13, xtype=XType.point3d),
  64. 'invisible_edge': DXFAttr(70, default=0),
  65. })