block.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Created: 25.03.2011
  2. # Copyright (c) 2011-2018, Manfred Moitzi
  3. # License: MIT License
  4. from ezdxf.legacy import block
  5. from .graphics import ExtendedTags, DXFAttr, DefSubclass, DXFAttributes, XType
  6. from .graphics import none_subclass, ModernGraphicEntityExtension, ModernGraphicEntity
  7. _BLOCK_TPL = """0
  8. BLOCK
  9. 5
  10. 0
  11. 330
  12. 0
  13. 100
  14. AcDbEntity
  15. 8
  16. 0
  17. 100
  18. AcDbBlockBegin
  19. 2
  20. BLOCKNAME
  21. 3
  22. BLOCKNAME
  23. 70
  24. 0
  25. 10
  26. 0.0
  27. 20
  28. 0.0
  29. 30
  30. 0.0
  31. 1
  32. """
  33. block_subclass = (
  34. DefSubclass('AcDbEntity', {'layer': DXFAttr(8, default='0')}),
  35. DefSubclass('AcDbBlockBegin', {
  36. 'name': DXFAttr(2),
  37. 'name2': DXFAttr(3),
  38. 'description': DXFAttr(4),
  39. 'flags': DXFAttr(70),
  40. 'base_point': DXFAttr(10, xtype=XType.any_point),
  41. 'xref_path': DXFAttr(1, default=""),
  42. })
  43. )
  44. class Block(block.Block, ModernGraphicEntityExtension):
  45. __slots__ = ()
  46. TEMPLATE = ExtendedTags.from_text(_BLOCK_TPL)
  47. DXFATTRIBS = DXFAttributes(none_subclass, *block_subclass)
  48. _ENDBLOCK_TPL = """0
  49. ENDBLK
  50. 5
  51. 0
  52. 330
  53. 0
  54. 100
  55. AcDbEntity
  56. 8
  57. 0
  58. 100
  59. AcDbBlockEnd
  60. """
  61. endblock_subclass = (
  62. DefSubclass('AcDbEntity', {'layer': DXFAttr(8, default='0')}),
  63. DefSubclass('AcDbBlockEnd', {}),
  64. )
  65. class EndBlk(ModernGraphicEntity):
  66. __slots__ = ()
  67. TEMPLATE = ExtendedTags.from_text(_ENDBLOCK_TPL)
  68. DXFATTRIBS = DXFAttributes(none_subclass, *endblock_subclass)