attrib.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. # Created: 25.03.2011
  2. # Copyright (c) 2011-2018, Manfred Moitzi
  3. # License: MIT License
  4. from ezdxf.legacy import attrib
  5. from .graphics import ExtendedTags, DXFAttr, DefSubclass, DXFAttributes, XType
  6. from .graphics import none_subclass, entity_subclass, ModernGraphicEntityExtension
  7. _ATTDEF_TPL = """0
  8. ATTDEF
  9. 5
  10. 0
  11. 330
  12. 0
  13. 100
  14. AcDbEntity
  15. 8
  16. 0
  17. 100
  18. AcDbText
  19. 10
  20. 0.0
  21. 20
  22. 0.0
  23. 30
  24. 0.0
  25. 40
  26. 1.0
  27. 1
  28. DEFAULTTEXT
  29. 50
  30. 0.0
  31. 51
  32. 0.0
  33. 41
  34. 1.0
  35. 7
  36. STANDARD
  37. 71
  38. 0
  39. 72
  40. 0
  41. 11
  42. 0.0
  43. 21
  44. 0.0
  45. 31
  46. 0.0
  47. 100
  48. AcDbAttributeDefinition
  49. 3
  50. PROMPTTEXT
  51. 2
  52. TAG
  53. 70
  54. 0
  55. 73
  56. 0
  57. 74
  58. 0
  59. """
  60. attdef_subclass = (
  61. DefSubclass('AcDbText', {
  62. 'insert': DXFAttr(10, xtype=XType.any_point),
  63. 'thickness': DXFAttr(39, default=0.0),
  64. 'height': DXFAttr(40),
  65. 'text': DXFAttr(1),
  66. 'rotation': DXFAttr(50, default=0.0),
  67. 'width': DXFAttr(41, default=1.0),
  68. 'oblique': DXFAttr(51, default=0.0),
  69. 'style': DXFAttr(7, default='STANDARD'),
  70. 'text_generation_flag': DXFAttr(71, default=0),
  71. 'halign': DXFAttr(72, default=0),
  72. 'align_point': DXFAttr(11, xtype=XType.any_point),
  73. 'extrusion': DXFAttr(210, xtype=XType.point3d, default=(0.0, 0.0, 1.0)),
  74. }),
  75. DefSubclass('AcDbAttributeDefinition', {
  76. 'prompt': DXFAttr(3),
  77. 'tag': DXFAttr(2),
  78. 'flags': DXFAttr(70),
  79. 'field_length': DXFAttr(73, default=0),
  80. 'valign': DXFAttr(74, default=0),
  81. })
  82. )
  83. class Attdef(attrib.Attdef, ModernGraphicEntityExtension):
  84. __slots__ = ()
  85. TEMPLATE = ExtendedTags.from_text(_ATTDEF_TPL)
  86. DXFATTRIBS = DXFAttributes(none_subclass, entity_subclass, *attdef_subclass)
  87. _ATTRIB_TPL = """0
  88. ATTRIB
  89. 5
  90. 0
  91. 330
  92. 0
  93. 100
  94. AcDbEntity
  95. 8
  96. 0
  97. 100
  98. AcDbText
  99. 10
  100. 0.0
  101. 20
  102. 0.0
  103. 30
  104. 0.0
  105. 40
  106. 1.0
  107. 1
  108. DEFAULTTEXT
  109. 50
  110. 0.0
  111. 51
  112. 0.0
  113. 41
  114. 1.0
  115. 7
  116. STANDARD
  117. 72
  118. 0
  119. 11
  120. 0.0
  121. 21
  122. 0.0
  123. 31
  124. 0.0
  125. 100
  126. AcDbAttribute
  127. 2
  128. TAG
  129. 70
  130. 0
  131. 71
  132. 0
  133. 73
  134. 0
  135. 74
  136. 0
  137. """
  138. attrib_subclass = (
  139. DefSubclass('AcDbText', {
  140. 'insert': DXFAttr(10, xtype=XType.any_point),
  141. 'thickness': DXFAttr(39, default=0.0),
  142. 'height': DXFAttr(40),
  143. 'text': DXFAttr(1),
  144. 'rotation': DXFAttr(50, default=0.0), # error in DXF description, because placed in 'AcDbAttribute'
  145. 'width': DXFAttr(41, default=1.0), # error in DXF description, because placed in 'AcDbAttribute'
  146. 'oblique': DXFAttr(51, default=0.0), # error in DXF description, because placed in 'AcDbAttribute'
  147. 'style': DXFAttr(7, default='STANDARD'), # error in DXF description, because placed in 'AcDbAttribute'
  148. 'extrusion': DXFAttr(210, xtype=XType.point3d, default=(0.0, 0.0, 1.0)), # error in DXF description, because placed in 'AcDbAttribute'
  149. 'halign': DXFAttr(72, default=0),
  150. 'align_point': DXFAttr(11, xtype=XType.any_point),
  151. }),
  152. DefSubclass('AcDbAttribute', {
  153. 'tag': DXFAttr(2),
  154. 'flags': DXFAttr(70),
  155. 'field_length': DXFAttr(73, default=0),
  156. 'text_generation_flag': DXFAttr(71, default=0),
  157. 'valign': DXFAttr(74, default=0),
  158. })
  159. )
  160. class Attrib(attrib.Attrib, ModernGraphicEntityExtension):
  161. __slots__ = ()
  162. TEMPLATE = ExtendedTags.from_text(_ATTRIB_TPL)
  163. DXFATTRIBS = DXFAttributes(none_subclass, entity_subclass, *attrib_subclass)