Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Treyer <treyer@arch.ethz.ch>2016-08-16 19:24:32 +0300
committerLukas Treyer <treyer@arch.ethz.ch>2016-08-16 19:24:32 +0300
commit37939a32083be2ca80b296bd8b030bffaf65928d (patch)
tree404adb02f8c644b9ac11d3eb65da1005a5334dd1 /io_import_dxf/dxfgrabber/styles.py
parentb79cc04f772aefab48e0a9769b1d0dae73198ec8 (diff)
updating to newest version of dxfgrabber; needed for further updates regarding inf.0 problem.
Diffstat (limited to 'io_import_dxf/dxfgrabber/styles.py')
-rw-r--r--[-rwxr-xr-x]io_import_dxf/dxfgrabber/styles.py91
1 files changed, 34 insertions, 57 deletions
diff --git a/io_import_dxf/dxfgrabber/styles.py b/io_import_dxf/dxfgrabber/styles.py
index 8553bc4f..3d5dc5e0 100755..100644
--- a/io_import_dxf/dxfgrabber/styles.py
+++ b/io_import_dxf/dxfgrabber/styles.py
@@ -5,75 +5,52 @@
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
-from .dxfentity import DXFEntity
from .layers import Table
-from .dxfattr import DXFAttr, DXFAttributes, DefSubclass
-from .tags import ClassifiedTags
+from .tags import Tags
class Style(object):
- def __init__(self, wrapper):
- self.name = wrapper.get_dxf_attrib('name')
- self.height = wrapper.get_dxf_attrib('height')
- self.width = wrapper.get_dxf_attrib('width')
- self.oblique = wrapper.get_dxf_attrib('oblique')
- # backward & mirror_y was first and stays for compatibility
- self.backward = bool(wrapper.get_dxf_attrib('generation_flags') & 2)
- self.mirror_y = bool(wrapper.get_dxf_attrib('generation_flags') & 4)
- self.is_backwards = self.backward
- self.is_upside_down = self.mirror_y
- self.font = wrapper.get_dxf_attrib('font')
- self.bigfont = wrapper.get_dxf_attrib('bigfont', "")
+ def __init__(self, tags):
+ self.name = ""
+ self.height = 1.0
+ self.width = 1.0
+ self.oblique = 0.
+ self.is_backwards = False
+ self.is_upside_down = False
+ self.font = ""
+ self.big_font = ""
+ for code, value in tags.plain_tags():
+ if code == 2:
+ self.name = value
+ elif code == 70:
+ self.flags = value
+ elif code == 40:
+ self.height = value
+ elif code == 41:
+ self.width = value
+ elif code == 50:
+ self.oblique = value
+ elif code == 71:
+ self.is_backwards = bool(value & 2)
+ self.is_upside_down = bool(value & 4)
+ self.oblique = value
+ elif code == 3:
+ self.font = value
+ elif code == 4:
+ self.big_font = value
class StyleTable(Table):
name = 'styles'
@staticmethod
- def from_tags(tags, drawing):
- dxfversion = drawing.dxfversion
+ def from_tags(tags):
styles = StyleTable()
- for entrytags in styles._classified_tags(tags):
- dxfstyle = styles.wrap(entrytags, dxfversion)
- styles._table_entries[dxfstyle.get_dxf_attrib('name')] = Style(dxfstyle)
+ for entry_tags in styles.entry_tags(tags):
+ style = Style(entry_tags)
+ styles._table_entries[style.name] = style
return styles
- @staticmethod
- def wrap(tags, dxfversion):
- return DXF12Style(tags) if dxfversion == "AC1009" else DXF13Style(tags)
-
-
-class DXF12Style(DXFEntity):
- DXFATTRIBS = DXFAttributes(DefSubclass(None, {
- 'handle': DXFAttr(5),
- 'name': DXFAttr(2),
- 'flags': DXFAttr(70),
- 'height': DXFAttr(40), # fixed height, 0 if not fixed
- 'width': DXFAttr(41), # width factor
- 'oblique': DXFAttr(50), # oblique angle in degree, 0 = vertical
- 'generation_flags': DXFAttr(71), # 2 = backward, 4 = mirrored in Y
- 'last_height': DXFAttr(42), # last height used
- 'font': DXFAttr(3), # primary font file name
- 'bigfont': DXFAttr(4), # big font name, blank if none
- }))
-
-none_subclass = DefSubclass(None, {'handle': DXFAttr(5)})
-symbol_subclass = DefSubclass('AcDbSymbolTableRecord', {})
-style_subclass = DefSubclass('AcDbTextStyleTableRecord', {
- 'name': DXFAttr(2),
- 'flags': DXFAttr(70),
- 'height': DXFAttr(40), # fixed height, 0 if not fixed
- 'width': DXFAttr(41), # width factor
- 'oblique': DXFAttr(50), # oblique angle in degree, 0 = vertical
- 'generation_flags': DXFAttr(71), # 2 = backward, 4 = mirrored in Y
- 'last_height': DXFAttr(42), # last height used
- 'font': DXFAttr(3), # primary font file name
- 'bigfont': DXFAttr(4), # big font name, blank if none
-})
-
-
-class DXF13Style(DXF12Style):
- DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass, style_subclass)
DEFAULT_STYLE = """ 0
STYLE
@@ -97,4 +74,4 @@ Arial
"""
-default_text_style = Style(DXF12Style(ClassifiedTags.from_text(DEFAULT_STYLE))) \ No newline at end of file
+default_text_style = Style(Tags.from_text(DEFAULT_STYLE))