tablestyle.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Created: 10.04.2018
  2. # Copyright (c) 2018, Manfred Moitzi
  3. # License: MIT-License
  4. from typing import TYPE_CHECKING
  5. from .dxfobjects import DXFObject, DefSubclass, DXFAttributes, DXFAttr, none_subclass, ExtendedTags
  6. from .object_manager import ObjectManager
  7. if TYPE_CHECKING:
  8. from ezdxf.eztypes import Drawing
  9. _TABLESTYLE_CLS = """0
  10. CLASS
  11. 1
  12. TABLESTYLE
  13. 2
  14. AcDbTableStyle
  15. 3
  16. ObjectDBX Classes
  17. 90
  18. 4095
  19. 91
  20. 0
  21. 280
  22. 0
  23. 281
  24. 0
  25. """
  26. _TABLESTYLE_TPL = """0
  27. TABLESTYLE
  28. 5
  29. 0
  30. 102
  31. {ACAD_REACTORS
  32. 330
  33. 0
  34. 102
  35. }
  36. 330
  37. 0
  38. 100
  39. AcDbTableStyle
  40. 280
  41. 0
  42. 3
  43. Standard
  44. 70
  45. 0
  46. 71
  47. 0
  48. 40
  49. 1.5
  50. 41
  51. 1.5
  52. 280
  53. 0
  54. 281
  55. 0
  56. """
  57. tablestyle_subclass = DefSubclass('AcDbTableStyle', {
  58. 'version': DXFAttr(280), # 0 = 2010
  59. 'name': DXFAttr(3), # Table style description (string; 255 characters maximum)
  60. 'flow_direction': DXFAttr(7), # FlowDirection (integer):
  61. # 0 = Down
  62. # 1 = Up
  63. 'flags': DXFAttr(7), # Flags (bit-coded)
  64. 'horizontal_cell_margin': DXFAttr(40), # Horizontal cell margin (real; default = 0.06)
  65. 'vertical_cell_margin': DXFAttr(41), # Vertical cell margin (real; default = 0.06)
  66. 'suppress_title': DXFAttr(280), # Flag for whether the title is suppressed: 0/1 = not suppressed/suppressed
  67. 'suppress_column_header': DXFAttr(281), # Flag for whether the column heading is suppressed: 0/1 = not suppressed/suppressed
  68. # The following group codes are repeated for every cell in the table
  69. # 7: Text style name (string; default = STANDARD)
  70. # 140: Text height (real)
  71. # 170: Cell alignment (integer)
  72. # 62: Text color (integer; default = BYBLOCK)
  73. # 63: Cell fill color (integer; default = 7)
  74. # 283: Flag for whether background color is enabled (default = 0): 0/1 = disabled/enabled
  75. # 90: Cell data type
  76. # 91: Cell unit type
  77. # 274-279: Lineweight associated with each border type of the cell (default = kLnWtByBlock)
  78. # 284-289: Flag for visibility associated with each border type of the cell (default = 1): 0/1 = Invisible/Visible
  79. # 64-69: Color value associated with each border type of the cell (default = BYBLOCK)
  80. })
  81. class TableStyle(DXFObject):
  82. """
  83. Every ACAD_TABLE has its own table style.
  84. Requires DXF version AC1021/R2007
  85. """
  86. __slots__ = ()
  87. TEMPLATE = ExtendedTags.from_text(_TABLESTYLE_TPL)
  88. CLASS = ExtendedTags.from_text(_TABLESTYLE_CLS)
  89. DXFATTRIBS = DXFAttributes(none_subclass, tablestyle_subclass)
  90. class TableStyleManager(ObjectManager):
  91. def __init__(self, drawing: 'Drawing'):
  92. super().__init__(drawing, dict_name='ACAD_TABLESTYLE', object_type='TABLESTYLE')