tableentries.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. # Created: 16.03.2011
  2. # Copyright (c) 2011-2018, Manfred Moitzi
  3. # License: MIT License
  4. from typing import TYPE_CHECKING, Iterable, Union, cast, Optional
  5. import logging
  6. from ezdxf.lldxf.types import DXFTag
  7. from ezdxf.lldxf.extendedtags import ExtendedTags
  8. from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass, XType, VIRTUAL_TAG
  9. from ezdxf.lldxf.const import DXFKeyError, LINEWEIGHT_BYBLOCK, DXFVersionError
  10. from ezdxf.legacy import tableentries as legacy
  11. from ezdxf.dxfentity import DXFEntity
  12. from ezdxf.tools.complex_ltype import lin_compiler
  13. from ezdxf.render.arrows import ARROWS
  14. logger = logging.getLogger('ezdxf')
  15. if TYPE_CHECKING:
  16. from ezdxf.eztypes import Drawing, ComplexLineTypePart
  17. _LAYERTEMPLATE = """0
  18. LAYER
  19. 5
  20. LayerHandle
  21. 100
  22. AcDbSymbolTableRecord
  23. 100
  24. AcDbLayerTableRecord
  25. 2
  26. LayerName
  27. 70
  28. 0
  29. 62
  30. 7
  31. 6
  32. Continuous
  33. 290
  34. 1
  35. 390
  36. 0
  37. """
  38. # code 390 is required for AutoCAD
  39. # Pointer/handle to PlotStyleName
  40. # uses tag(390, ...) from the '0' layer
  41. none_subclass = DefSubclass(None, {
  42. 'handle': DXFAttr(5),
  43. 'owner': DXFAttr(330),
  44. })
  45. symbol_subclass = DefSubclass('AcDbSymbolTableRecord', {})
  46. layer_subclass = DefSubclass('AcDbLayerTableRecord', {
  47. 'name': DXFAttr(2), # layer name
  48. 'flags': DXFAttr(70),
  49. 'color': DXFAttr(62), # dxf color index
  50. 'linetype': DXFAttr(6), # linetype name
  51. 'plot': DXFAttr(290), # don't plot this layer if 0 else 1
  52. 'line_weight': DXFAttr(370), # enum value???
  53. 'lineweight': DXFAttr(370), # enum value???
  54. 'plot_style_name': DXFAttr(390), # handle to PlotStyleName object
  55. 'material': DXFAttr(347), # handle to Material object
  56. })
  57. class Layer(legacy.Layer):
  58. __slots__ = ()
  59. TEMPLATE = ExtendedTags.from_text(_LAYERTEMPLATE)
  60. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, layer_subclass)
  61. @classmethod
  62. def new(cls, handle: str, dxfattribs: dict = None, drawing: 'Drawing' = None) -> 'Layer':
  63. layer = super(Layer, cls).new(handle, dxfattribs, drawing)
  64. # just for testing scenarios where drawing is None
  65. if drawing is not None:
  66. layer.dxf.plot_style_name = drawing.rootdict['ACAD_PLOTSTYLENAME']
  67. return layer
  68. _STYLETEMPLATE = """0
  69. STYLE
  70. 5
  71. 0
  72. 100
  73. AcDbSymbolTableRecord
  74. 100
  75. AcDbTextStyleTableRecord
  76. 2
  77. STYLENAME
  78. 70
  79. 0
  80. 40
  81. 0.0
  82. 41
  83. 1.0
  84. 50
  85. 0.0
  86. 71
  87. 0
  88. 42
  89. 0.2
  90. 3
  91. arial.ttf
  92. 4
  93. """
  94. style_subclass = DefSubclass('AcDbTextStyleTableRecord', {
  95. 'name': DXFAttr(2),
  96. 'flags': DXFAttr(70),
  97. 'height': DXFAttr(40), # fixed height, 0 if not fixed
  98. 'width': DXFAttr(41), # width factor
  99. 'oblique': DXFAttr(50), # oblique angle in degree, 0 = vertical
  100. 'generation_flags': DXFAttr(71), # 2 = backward, 4 = mirrored in Y
  101. 'last_height': DXFAttr(42), # last height used
  102. 'font': DXFAttr(3), # primary font file name
  103. 'bigfont': DXFAttr(4), # big font name, blank if none
  104. })
  105. class Style(legacy.Style):
  106. __slots__ = ()
  107. TEMPLATE = ExtendedTags.from_text(_STYLETEMPLATE)
  108. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, style_subclass)
  109. _LTYPETEMPLATE = """0
  110. LTYPE
  111. 5
  112. 0
  113. 100
  114. AcDbSymbolTableRecord
  115. 100
  116. AcDbLinetypeTableRecord
  117. 2
  118. LTYPENAME
  119. 70
  120. 0
  121. 3
  122. LTYPEDESCRIPTION
  123. 72
  124. 65
  125. """
  126. linetype_subclass = DefSubclass('AcDbLinetypeTableRecord', {
  127. 'name': DXFAttr(2),
  128. 'description': DXFAttr(3),
  129. 'length': DXFAttr(40),
  130. 'items': DXFAttr(73),
  131. })
  132. class Linetype(legacy.Linetype):
  133. __slots__ = ()
  134. TEMPLATE = ExtendedTags.from_text(_LTYPETEMPLATE)
  135. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, linetype_subclass)
  136. def _setup_pattern(self, pattern: Union[Iterable[float], str], length: float) -> None:
  137. complex_line_type = True if isinstance(pattern, str) else False
  138. if complex_line_type: # a .lin like line type definition string
  139. self._setup_complex_pattern(pattern, length)
  140. else:
  141. # pattern: [2.0, 1.25, -0.25, 0.25, -0.25] - 1. element is total pattern length
  142. # pattern elements: >0 line, <0 gap, =0 point
  143. subclass = self.tags.get_subclass('AcDbLinetypeTableRecord')
  144. subclass.append(DXFTag(73, len(pattern) - 1))
  145. subclass.append(DXFTag(40, float(pattern[0])))
  146. for element in pattern[1:]:
  147. subclass.append(DXFTag(49, float(element)))
  148. subclass.append(DXFTag(74, 0))
  149. def _setup_complex_pattern(self, pattern: str, length: float) -> None:
  150. tokens = lin_compiler(pattern)
  151. subclass = self.tags.get_subclass('AcDbLinetypeTableRecord')
  152. subclass.append(DXFTag(73, 0)) # temp length of 0
  153. subclass.append(DXFTag(40, length))
  154. count = 0
  155. for token in tokens:
  156. if isinstance(token, DXFTag):
  157. if subclass[-1].code == 49: # useless 74 only after 49 :))
  158. subclass.append(DXFTag(74, 0))
  159. subclass.append(token)
  160. count += 1
  161. else: # TEXT or SHAPE
  162. tags = cast('ComplexLineTypePart', token).complex_ltype_tags(self.drawing)
  163. subclass.extend(tags)
  164. subclass.append(DXFTag(74, 0)) # useless 74 at the end :))
  165. subclass.update(DXFTag(73, count))
  166. _APPIDTEMPLATE = """0
  167. APPID
  168. 5
  169. 0
  170. 100
  171. AcDbSymbolTableRecord
  172. 100
  173. AcDbRegAppTableRecord
  174. 2
  175. APPIDNAME
  176. 70
  177. 0
  178. """
  179. appid_subclass = DefSubclass('AcDbRegAppTableRecord', {
  180. 'name': DXFAttr(2),
  181. 'flags': DXFAttr(70),
  182. })
  183. class AppID(legacy.AppID):
  184. __slots__ = ()
  185. TEMPLATE = ExtendedTags.from_text(_APPIDTEMPLATE)
  186. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, appid_subclass)
  187. _DIMSTYLETEMPLATE = """0
  188. DIMSTYLE
  189. 105
  190. 0
  191. 100
  192. AcDbSymbolTableRecord
  193. 100
  194. AcDbDimStyleTableRecord
  195. 2
  196. STANDARD
  197. 70
  198. 0
  199. 3
  200. 4
  201. 40
  202. 1.0
  203. 41
  204. 3.0
  205. 42
  206. 2.0
  207. 43
  208. 9.0
  209. 44
  210. 5.0
  211. 46
  212. 0.0
  213. 47
  214. 0.0
  215. 48
  216. 0.0
  217. 140
  218. 3.0
  219. 141
  220. 2.0
  221. 142
  222. 0.0
  223. 143
  224. 25.399999999999999
  225. 144
  226. 1.0
  227. 145
  228. 0.0
  229. 146
  230. 1.0
  231. 147
  232. 2.0
  233. 71
  234. 0
  235. 72
  236. 0
  237. 73
  238. 1
  239. 74
  240. 1
  241. 75
  242. 0
  243. 76
  244. 0
  245. 77
  246. 0
  247. 78
  248. 0
  249. 170
  250. 0
  251. 171
  252. 2
  253. 172
  254. 0
  255. 173
  256. 0
  257. 174
  258. 0
  259. 175
  260. 0
  261. 176
  262. 0
  263. 177
  264. 0
  265. 178
  266. 0
  267. """
  268. handle105_subclass = DefSubclass(None, {
  269. 'handle': DXFAttr(105),
  270. 'owner': DXFAttr(330),
  271. })
  272. dimstyle_subclass = DefSubclass('AcDbDimStyleTableRecord', {
  273. 'name': DXFAttr(2),
  274. 'flags': DXFAttr(70),
  275. 'dimpost': DXFAttr(3),
  276. 'dimapost': DXFAttr(4),
  277. # redirect dimblk/dimblk1/dimblk2 -> dimblk_handle/dimblk1_handle/dimblk2_handle
  278. 'dimblk': DXFAttr(5, xtype=XType.callback, getter='get_dimblk', setter='set_dimblk'),
  279. 'dimblk1': DXFAttr(6, xtype=XType.callback, getter='get_dimblk1', setter='set_dimblk1'),
  280. 'dimblk2': DXFAttr(7, xtype=XType.callback, getter='get_dimblk2', setter='set_dimblk2'),
  281. 'dimscale': DXFAttr(40),
  282. 'dimasz': DXFAttr(41),
  283. 'dimexo': DXFAttr(42),
  284. 'dimdli': DXFAttr(43),
  285. 'dimexe': DXFAttr(44),
  286. 'dimrnd': DXFAttr(45),
  287. 'dimdle': DXFAttr(46),
  288. 'dimtp': DXFAttr(47),
  289. 'dimtm': DXFAttr(48),
  290. 'dimfxl': DXFAttr(49, dxfversion='AC1021'), # undocumented: length of extension line if fixed (dimfxlon = 1)
  291. 'dimtxt': DXFAttr(140),
  292. 'dimcen': DXFAttr(141),
  293. 'dimtsz': DXFAttr(142),
  294. 'dimaltf': DXFAttr(143),
  295. 'dimlfac': DXFAttr(144),
  296. 'dimtvp': DXFAttr(145),
  297. 'dimtfac': DXFAttr(146),
  298. 'dimgap': DXFAttr(147),
  299. 'dimaltrnd': DXFAttr(148),
  300. 'dimtfill': DXFAttr(69, dxfversion='AC1021'), # 0=None, 1=canvas color, 2=dimtfillclr
  301. 'dimtfillclr': DXFAttr(70, dxfversion='AC1021'), # color index for dimtfill==2
  302. 'dimtol': DXFAttr(71),
  303. 'dimlim': DXFAttr(72),
  304. 'dimtih': DXFAttr(73),
  305. 'dimtoh': DXFAttr(74),
  306. 'dimse1': DXFAttr(75),
  307. 'dimse2': DXFAttr(76),
  308. 'dimtad': DXFAttr(77),
  309. 'dimzin': DXFAttr(78),
  310. 'dimazin': DXFAttr(79),
  311. 'dimalt': DXFAttr(170),
  312. 'dimaltd': DXFAttr(171),
  313. 'dimtofl': DXFAttr(172),
  314. 'dimsah': DXFAttr(173),
  315. 'dimtix': DXFAttr(174),
  316. 'dimsoxd': DXFAttr(175),
  317. 'dimclrd': DXFAttr(176),
  318. 'dimclre': DXFAttr(177),
  319. 'dimclrt': DXFAttr(178),
  320. 'dimadec': DXFAttr(179),
  321. 'dimunit': DXFAttr(270),
  322. 'dimdec': DXFAttr(271),
  323. 'dimtdec': DXFAttr(272),
  324. 'dimaltu': DXFAttr(273),
  325. 'dimalttd': DXFAttr(274),
  326. 'dimaunit': DXFAttr(275),
  327. 'dimfrac': DXFAttr(276),
  328. 'dimlunit': DXFAttr(277),
  329. 'dimdsep': DXFAttr(278),
  330. 'dimtmove': DXFAttr(279),
  331. 'dimjust': DXFAttr(280),
  332. 'dimsd1': DXFAttr(281),
  333. 'dimsd2': DXFAttr(282),
  334. 'dimtolj': DXFAttr(283),
  335. 'dimtzin': DXFAttr(284),
  336. 'dimaltz': DXFAttr(285),
  337. 'dimalttz': DXFAttr(286),
  338. 'dimfit': DXFAttr(287), # obsolete, now use DIMATFIT and DIMTMOVE
  339. 'dimupt': DXFAttr(288),
  340. 'dimatfit': DXFAttr(289),
  341. 'dimfxlon': DXFAttr(290, dxfversion='AC1021'), # undocumented: 1 = fixed extension line length
  342. 'dimtxsty_handle': DXFAttr(340), # handle of referenced STYLE entry
  343. # virtual DXF attribute 'dimtxsty': set/get referenced STYLE by name as callback
  344. 'dimtxsty': DXFAttr(VIRTUAL_TAG, xtype=XType.callback, getter='get_text_style', setter='set_text_style'),
  345. # virtual DXF attribute 'dimldrblk': set/get referenced STYLE by name as callback
  346. 'dimldrblk': DXFAttr(VIRTUAL_TAG, xtype=XType.callback, getter='get_dimldrblk', setter='set_dimldrblk'),
  347. 'dimldrblk_handle': DXFAttr(341), # handle of referenced BLOCK_RECORD
  348. 'dimblk_handle': DXFAttr(342), # handle of referenced BLOCK_RECORD
  349. 'dimblk1_handle': DXFAttr(343), # handle of referenced BLOCK_RECORD
  350. 'dimblk2_handle': DXFAttr(344), # handle of referenced BLOCK_RECORD
  351. 'dimltype_handle': DXFAttr(345, dxfversion='AC1021'), # handle of linetype for dimension line
  352. # virtual DXF attribute 'dimldtype': set/get referenced LINETYPE by name as callback
  353. 'dimltype': DXFAttr(VIRTUAL_TAG,
  354. xtype=XType.callback,
  355. getter='get_linetype',
  356. setter='set_linetype',
  357. dxfversion='AC1021'),
  358. 'dimltex1_handle': DXFAttr(346, dxfversion='AC1021'), # handle of linetype for extension line 1
  359. # virtual DXF attribute 'dimltex1': set/get referenced LINETYPE by name as callback
  360. 'dimltex1': DXFAttr(VIRTUAL_TAG,
  361. xtype=XType.callback,
  362. getter='get_ext1_linetype',
  363. setter='set_ext1_linetype',
  364. dxfversion='AC1021'),
  365. 'dimltex2_handle': DXFAttr(347, dxfversion='AC1021'), # handle of linetype for extension line 2
  366. # virtual DXF attribute 'dimltex2': set/get referenced LINETYPE by name as callback
  367. 'dimltex2': DXFAttr(VIRTUAL_TAG,
  368. xtype=XType.callback,
  369. getter='get_ext2_linetype',
  370. setter='set_ext2_linetype',
  371. dxfversion='AC1021'),
  372. 'dimlwd': DXFAttr(371, default=LINEWEIGHT_BYBLOCK), # dimension line lineweight enum value, default BYBLOCK
  373. 'dimlwe': DXFAttr(372, default=LINEWEIGHT_BYBLOCK), # extension line lineweight enum value, default BYBLOCK
  374. })
  375. class DimStyle(legacy.DimStyle):
  376. __slots__ = ()
  377. TEMPLATE = ExtendedTags.from_text(_DIMSTYLETEMPLATE)
  378. DXFATTRIBS = DXFAttributes(handle105_subclass, symbol_subclass, dimstyle_subclass)
  379. CODE_TO_DXF_ATTRIB = dict(DXFATTRIBS.build_group_code_items(legacy.dim_filter))
  380. def _set_blk_handle(self, attr: str, arrow_name: str) -> None:
  381. if arrow_name == ARROWS.closed_filled:
  382. # special arrow, no handle needed (is '0' if set)
  383. # do not create block by default, this will be done if arrow is used
  384. # and block record handle is not needed here
  385. self.del_dxf_attrib(attr)
  386. return
  387. blocks = self.drawing.blocks
  388. if ARROWS.is_acad_arrow(arrow_name):
  389. # create block, because need block record handle is needed here
  390. block_name = ARROWS.create_block(blocks, arrow_name)
  391. else:
  392. block_name = arrow_name
  393. blk = blocks.get(block_name)
  394. self.set_dxf_attrib(attr, blk.block_record_handle)
  395. def _get_arrow_block_name(self, name: str) -> str:
  396. handle = self.get_dxf_attrib(name, None)
  397. if handle in (None, '0'):
  398. # unset handle or handle '0' is default closed filled arrow
  399. return ARROWS.closed_filled
  400. else:
  401. block_name = get_block_name_by_handle(handle, self.drawing)
  402. return ARROWS.arrow_name(block_name) # if arrow return standard arrow name else just the block name
  403. def get_text_style(self) -> str:
  404. handle = self.get_dxf_attrib('dimtxsty_handle', None)
  405. if handle:
  406. return get_text_style_by_handle(handle, self.drawing)
  407. else:
  408. logging.warning('DIMSTYLE "{}": text style handle not set.'.format(self.dxf.name))
  409. return 'STANARD'
  410. def set_text_style(self, name: str) -> None:
  411. style = self.drawing.styles.get(name)
  412. self.set_dxf_attrib('dimtxsty_handle', style.dxf.handle)
  413. def get_dimblk(self) -> str:
  414. return self._get_arrow_block_name('dimblk_handle')
  415. def set_dimblk(self, name) -> None:
  416. self._set_blk_handle('dimblk_handle', name)
  417. def get_dimblk1(self) -> str:
  418. return self._get_arrow_block_name('dimblk1_handle')
  419. def set_dimblk1(self, name) -> None:
  420. self._set_blk_handle('dimblk1_handle', name)
  421. def get_dimblk2(self) -> str:
  422. return self._get_arrow_block_name('dimblk2_handle')
  423. def set_dimblk2(self, name) -> None:
  424. self._set_blk_handle('dimblk2_handle', name)
  425. def get_dimldrblk(self) -> str:
  426. return self._get_arrow_block_name('dimldrblk_handle')
  427. def set_dimldrblk(self, name) -> None:
  428. self._set_blk_handle('dimldrblk_handle', name)
  429. def get_ltype_name(self, dimvar: str) -> Optional[str]:
  430. if self.dxfversion < 'AC1021':
  431. logger.debug('Linetype support for DIMSTYLE requires DXF R2007 or later.')
  432. handle = self.get_dxf_attrib(dimvar, None)
  433. if handle:
  434. ltype = self.drawing.get_dxf_entity(handle)
  435. return ltype.dxf.name
  436. else:
  437. return None
  438. def get_linetype(self):
  439. return self.get_ltype_name('dimltype_handle')
  440. def get_ext1_linetype(self):
  441. return self.get_ltype_name('dimltex1_handle')
  442. def get_ext2_linetype(self):
  443. return self.get_ltype_name('dimltex2_handle')
  444. def get_ltype_handle(self, linetype_name: str) -> str:
  445. ltype = self.drawing.linetypes.get(linetype_name)
  446. return ltype.dxf.handle
  447. def set_linetype(self, name: str) -> None:
  448. self.dxf.dimltype_handle = self.get_ltype_handle(name)
  449. def set_ext1_linetype(self, name: str) -> None:
  450. self.dxf.dimltex1_handle = self.get_ltype_handle(name)
  451. def set_ext2_linetype(self, name: str) -> None:
  452. self.dxf.dimltex2_handle = self.get_ltype_handle(name)
  453. def set_linetypes(self, dimline=None, ext1=None, ext2=None) -> None:
  454. if self.dxfversion >= 'AC1021':
  455. if dimline is not None:
  456. self.set_linetype(dimline)
  457. if ext1 is not None:
  458. self.set_ext1_linetype(ext1)
  459. if ext2 is not None:
  460. self.set_ext2_linetype(ext2)
  461. else:
  462. logger.debug('Linetype support requires DXF R2007 or later.')
  463. def get_text_style_by_handle(handle, drawing: 'Drawing', default='STANDARD') -> str:
  464. try:
  465. entry = drawing.get_dxf_entity(handle)
  466. except DXFKeyError:
  467. logging.warning('Invalid text style handle "{}".'.format(handle))
  468. text_style_name = default
  469. else:
  470. text_style_name = entry.dxf.name
  471. return text_style_name
  472. def get_block_name_by_handle(handle, drawing: 'Drawing', default='') -> str:
  473. try:
  474. entry = drawing.get_dxf_entity(handle)
  475. except DXFKeyError:
  476. block_name = default
  477. else:
  478. block_name = entry.dxf.name
  479. return block_name
  480. _UCSTEMPLATE = """0
  481. UCS
  482. 5
  483. 0
  484. 100
  485. AcDbSymbolTableRecord
  486. 100
  487. AcDbUCSTableRecord
  488. 2
  489. UCSNAME
  490. 70
  491. 0
  492. 10
  493. 0.0
  494. 20
  495. 0.0
  496. 30
  497. 0.0
  498. 11
  499. 1.0
  500. 21
  501. 0.0
  502. 31
  503. 0.0
  504. 12
  505. 0.0
  506. 22
  507. 1.0
  508. 32
  509. 0.0
  510. """
  511. ucs_subclass = DefSubclass('AcDbUCSTableRecord', {
  512. 'name': DXFAttr(2),
  513. 'flags': DXFAttr(70),
  514. 'origin': DXFAttr(10, xtype=XType.point3d),
  515. 'xaxis': DXFAttr(11, xtype=XType.point3d),
  516. 'yaxis': DXFAttr(12, xtype=XType.point3d),
  517. })
  518. class UCS(legacy.UCS):
  519. __slots__ = ()
  520. TEMPLATE = ExtendedTags.from_text(_UCSTEMPLATE)
  521. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, ucs_subclass)
  522. _VIEWTEMPLATE = """0
  523. VIEW
  524. 5
  525. 0
  526. 100
  527. AcDbSymbolTableRecord
  528. 100
  529. AcDbViewTableRecord
  530. 2
  531. VIEWNAME
  532. 70
  533. 0
  534. 10
  535. 0.0
  536. 20
  537. 0.0
  538. 11
  539. 1.0
  540. 21
  541. 1.0
  542. 31
  543. 1.0
  544. 12
  545. 0.0
  546. 22
  547. 0.0
  548. 32
  549. 0.0
  550. 40
  551. 70.
  552. 41
  553. 1.0
  554. 42
  555. 50.0
  556. 43
  557. 0.0
  558. 44
  559. 0.0
  560. 50
  561. 0.0
  562. 71
  563. 0
  564. """
  565. view_subclass = DefSubclass('AcDbViewTableRecord', {
  566. 'name': DXFAttr(2),
  567. 'flags': DXFAttr(70),
  568. 'height': DXFAttr(40),
  569. 'width': DXFAttr(41),
  570. 'center_point': DXFAttr(10, xtype=XType.point2d),
  571. 'direction_point': DXFAttr(11, xtype=XType.point3d),
  572. 'target_point': DXFAttr(12, xtype=XType.point3d),
  573. 'lens_length': DXFAttr(42),
  574. 'front_clipping': DXFAttr(43),
  575. 'back_clipping': DXFAttr(44),
  576. 'view_twist': DXFAttr(50),
  577. 'view_mode': DXFAttr(71),
  578. })
  579. class View(legacy.View):
  580. __slots__ = ()
  581. TEMPLATE = ExtendedTags.from_text(_VIEWTEMPLATE)
  582. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, view_subclass)
  583. _VPORTTEMPLATE = """0
  584. VPORT
  585. 5
  586. 0
  587. 100
  588. AcDbSymbolTableRecord
  589. 100
  590. AcDbViewportTableRecord
  591. 2
  592. VPORTNAME
  593. 70
  594. 0
  595. 10
  596. 0.0
  597. 20
  598. 0.0
  599. 11
  600. 1.0
  601. 21
  602. 1.0
  603. 12
  604. 70.0
  605. 22
  606. 50.0
  607. 13
  608. 0.0
  609. 23
  610. 0.0
  611. 14
  612. 0.5
  613. 24
  614. 0.5
  615. 15
  616. 0.5
  617. 25
  618. 0.5
  619. 16
  620. 0.0
  621. 26
  622. 0.0
  623. 36
  624. 1.0
  625. 17
  626. 0.0
  627. 27
  628. 0.0
  629. 37
  630. 0.0
  631. 40
  632. 70.
  633. 41
  634. 1.34
  635. 42
  636. 50.0
  637. 43
  638. 0.0
  639. 44
  640. 0.0
  641. 50
  642. 0.0
  643. 51
  644. 0.0
  645. 71
  646. 0
  647. 72
  648. 1000
  649. 73
  650. 1
  651. 74
  652. 3
  653. 75
  654. 0
  655. 76
  656. 0
  657. 77
  658. 0
  659. 78
  660. 0
  661. """
  662. vport_subclass = DefSubclass('AcDbViewportTableRecord', {
  663. 'name': DXFAttr(2),
  664. 'flags': DXFAttr(70),
  665. 'lower_left': DXFAttr(10, xtype=XType.point2d),
  666. 'upper_right': DXFAttr(11, xtype=XType.point2d),
  667. 'center_point': DXFAttr(12, xtype=XType.point2d),
  668. 'snap_base': DXFAttr(13, xtype=XType.point2d),
  669. 'snap_spacing': DXFAttr(14, xtype=XType.point2d),
  670. 'grid_spacing': DXFAttr(15, xtype=XType.point2d),
  671. 'direction_point': DXFAttr(16, xtype=XType.point3d),
  672. 'target_point': DXFAttr(17, xtype=XType.point3d),
  673. 'height': DXFAttr(40),
  674. 'aspect_ratio': DXFAttr(41),
  675. 'lens_length': DXFAttr(42),
  676. 'front_clipping': DXFAttr(43),
  677. 'back_clipping': DXFAttr(44),
  678. 'snap_rotation': DXFAttr(50),
  679. 'view_twist': DXFAttr(51),
  680. 'status': DXFAttr(68),
  681. 'view_mode': DXFAttr(71),
  682. 'circle_zoom': DXFAttr(72),
  683. 'fast_zoom': DXFAttr(73),
  684. 'ucs_icon': DXFAttr(74),
  685. 'snap_on': DXFAttr(75),
  686. 'grid_on': DXFAttr(76),
  687. 'snap_style': DXFAttr(77),
  688. 'snap_isopair': DXFAttr(78),
  689. })
  690. class VPort(legacy.VPort):
  691. __slots__ = ()
  692. TEMPLATE = ExtendedTags.from_text(_VPORTTEMPLATE)
  693. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, vport_subclass)
  694. _BLOCKRECORDTEMPLATE = """0
  695. BLOCK_RECORD
  696. 5
  697. 0
  698. 330
  699. 0
  700. 100
  701. AcDbSymbolTableRecord
  702. 100
  703. AcDbBlockTableRecord
  704. 2
  705. BLOCK_RECORD_NAME
  706. 340
  707. 0
  708. """
  709. blockrec_subclass = DefSubclass('AcDbBlockTableRecord', {
  710. 'name': DXFAttr(2),
  711. 'layout': DXFAttr(340),
  712. })
  713. class BlockRecord(DXFEntity):
  714. """ Internal Object - use at your own risk!
  715. Required fields:
  716. owner: Soft-pointer ID/handle to owner object
  717. layout: Hard-pointer ID/handle to associated LAYOUT object - is '0' if block definition
  718. """
  719. __slots__ = ()
  720. TEMPLATE = ExtendedTags.from_text(_BLOCKRECORDTEMPLATE)
  721. DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, blockrec_subclass)