summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 84ff716)
raw | patch | inline | side by side (parent: 84ff716)
author | alvinpenner <alvinpenner@users.sourceforge.net> | |
Sun, 17 May 2009 17:44:19 +0000 (17:44 +0000) | ||
committer | alvinpenner <alvinpenner@users.sourceforge.net> | |
Sun, 17 May 2009 17:44:19 +0000 (17:44 +0000) |
share/extensions/dxf_input.inx | patch | blob | history | |
share/extensions/dxf_input.py | patch | blob | history |
index 3ecb38a90827baac694b7c9919dc4d773398ef6e..e63cd4f2ae62808b04bd7ef35c4988dd2f7f7ee2 100644 (file)
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="auto" type="boolean" _gui-text="Use automatic scaling to size A4">true</param>
<param name="scale" type="string" _gui-text="Or, use manual scale factor">1.0</param>
+ <param name="encoding" type="enum" _gui-text="Character Encoding">
+ <item value="latin_1">Latin 1</item>
+ <item value="cp1250">CP 1250</item>
+ <item value="cp1252">CP 1252</item>
+ <item value="utf_8">UTF 8</item>
+ </param>
<input>
<extension>.dxf</extension>
<mimetype>image/x-svgz</mimetype>
index e4cfc3b554930f75266ed0f20a9f0f6da616d178..86e530aaa427f2b1164a69e35a48f9c6e5ae821d 100644 (file)
parser = inkex.optparse.OptionParser(usage="usage: %prog [options] SVGfile", option_class=inkex.InkOption)
parser.add_option("--auto", action="store", type="inkbool", dest="auto", default=True)
parser.add_option("--scale", action="store", type="string", dest="scale", default="1.0")
+parser.add_option("--encoding", action="store", type="string", dest="input_encode", default="latin_1")
(options, args) = parser.parse_args(inkex.sys.argv[1:])
doc = inkex.etree.parse(StringIO('<svg xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"></svg>'))
desc = inkex.etree.SubElement(doc.getroot(), 'desc', {})
xmax = get_group('10')
ymax = get_group('20')
if flag == 1 and line[0] == '2':
- layername = unicode(line[1], "iso-8859-1")
+ layername = unicode(line[1], options.input_encode)
attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '%s' % layername}
layer_nodes[layername] = inkex.etree.SubElement(doc.getroot(), 'g', attribs)
if flag == 2 and line[0] == '2':
- linename = unicode(line[1], "iso-8859-1")
+ linename = unicode(line[1], options.input_encode)
linetypes[linename] = []
if flag == 3 and line[0] == '2':
- stylename = unicode(line[1], "iso-8859-1")
+ stylename = unicode(line[1], options.input_encode)
if line[0] == '2' and line[1] == 'LAYER':
flag = 1
if line[0] == '2' and line[1] == 'LTYPE':
scale = 210.0/(xmax - xmin) # scale to A4 width
else:
scale = float(options.scale) # manual scale factor
-desc.text = '%s - scale = %f' % (unicode(args[0], "iso-8859-1"), scale)
+desc.text = '%s - scale = %f' % (unicode(args[0], options.input_encode), scale)
scale *= 90.0/25.4 # convert from mm to pixels
if not layer_nodes:
val = line[1].replace('\~', ' ')
val = inkex.re.sub( '\\\\A.*;', '', val)
val = inkex.re.sub( '\\\\H.*;', '', val)
+ val = inkex.re.sub( '\\^I', '', val)
+ val = inkex.re.sub( '\\\\L', '', val)
val = inkex.re.sub( '\\\\S.*;', '', val)
val = inkex.re.sub( '\\\\W.*;', '', val)
- val = unicode(val, "iso-8859-1")
+ val = unicode(val, options.input_encode)
val = val.encode('unicode_escape')
val = inkex.re.sub( '\\\\\\\\U\+([0-9A-Fa-f]{4})', '\\u\\1', val)
val = val.decode('unicode_escape')