section.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Created: 08.04.2018
  2. # Copyright (c) 2018, Manfred Moitzi
  3. # License: MIT-License
  4. from typing import TYPE_CHECKING, List
  5. from .graphics import ExtendedTags, DXFAttr, DefSubclass, DXFAttributes, XType
  6. from .graphics import none_subclass, entity_subclass, ModernGraphicEntity
  7. if TYPE_CHECKING:
  8. from ezdxf.eztypes import Tags, Vertex
  9. _SECTION_TPL = """0
  10. SECTION
  11. 5
  12. 0
  13. 330
  14. 0
  15. 100
  16. AcDbEntity
  17. 8
  18. 0
  19. 100
  20. AcDbSection
  21. 90
  22. 1
  23. 91
  24. 0
  25. 1
  26. NAME
  27. 10
  28. 0.0
  29. 11
  30. 0.0
  31. 12
  32. 1.0
  33. 40
  34. 1.0
  35. 41
  36. 0.0
  37. """
  38. section_subclass = DefSubclass('AcDbSection', {
  39. 'state': DXFAttr(90),
  40. 'flags': DXFAttr(91),
  41. 'name': DXFAttr(1),
  42. 'vertical_direction': DXFAttr(10, xtype=XType.point3d),
  43. 'top_height': DXFAttr(40),
  44. 'bottom_height': DXFAttr(41),
  45. 'indicator_transparency': DXFAttr(70),
  46. 'indicator_color': DXFAttr(63),
  47. 'indicator_true_color': DXFAttr(411),
  48. 'n_vertices': DXFAttr(92), # Number of vertices
  49. # 11: Vertex (repeats for number of vertices)
  50. 'n_back_line_vertices': DXFAttr(93), # Number of back line vertices
  51. # 12: Back line vertex (repeats for number of back line vertices)
  52. 'geometry_settings_id': DXFAttr(360), # Hard-pointer ID/handle to geometry settings object
  53. })
  54. class Section(ModernGraphicEntity):
  55. # Requires AC1021/R2007
  56. __slots__ = ()
  57. TEMPLATE = ExtendedTags.from_text(_SECTION_TPL)
  58. DXFATTRIBS = DXFAttributes(none_subclass, entity_subclass, section_subclass)
  59. @property
  60. def AcDbSection(self) -> 'Tags':
  61. return self.tags.subclasses[2]
  62. def get_vertices(self) -> List['Vertex']:
  63. return [vertex.value for vertex in self.AcDbSection.find_all(11)]
  64. def get_back_line_vertices(self) -> List['Vertex']:
  65. return [vertex.value for vertex in self.AcDbSection.find_all(12)]