summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 64bc9f1)
raw | patch | inline | side by side (parent: 64bc9f1)
author | alvinpenner <alvinpenner@users.sourceforge.net> | |
Sun, 1 Feb 2009 12:45:54 +0000 (12:45 +0000) | ||
committer | alvinpenner <alvinpenner@users.sourceforge.net> | |
Sun, 1 Feb 2009 12:45:54 +0000 (12:45 +0000) |
share/extensions/dxf_input.py | patch | blob | history |
index ffb1194c8a542dc613ee2f36e98681b5d0b539a1..b518969fe522b6c9cd6538c59b7556533579a6e5 100644 (file)
angle = vals[groups['50']][0]\r
attribs.update({'transform': 'rotate (%f %f %f)' % (-angle, x, y)})\r
attribs.update({'sodipodi:linespacing': '125%'})\r
- node = inkex.etree.SubElement(doc.getroot(), 'text', attribs)\r
+ node = inkex.etree.SubElement(layer, 'text', attribs)\r
text = vals[groups['1']][0]\r
found = text.find('\P') # new line\r
while found > -1:\r
if vals[groups['10']] and vals[groups['11']] and vals[groups['20']] and vals[groups['21']]:\r
path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], scale*(vals[groups['11']][0] - xmin), - scale*(vals[groups['21']][0] - ymax))\r
attribs = {'d': path, 'style': style}\r
- inkex.etree.SubElement(doc.getroot(), 'path', attribs)\r
+ inkex.etree.SubElement(layer, 'path', attribs)\r
\r
def export_SPLINE():\r
# mandatory group codes : (10, 20, 70) (x, y, flags)\r
if not (vals[groups['70']][0] & 3) and len(vals[groups['10']]) == 4 and len(vals[groups['20']]) == 4:\r
path = 'M %f,%f C %f,%f %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][1], vals[groups['20']][1], vals[groups['10']][2], vals[groups['20']][2], vals[groups['10']][3], vals[groups['20']][3])\r
attribs = {'d': path, 'style': style}\r
- inkex.etree.SubElement(doc.getroot(), 'path', attribs)\r
+ inkex.etree.SubElement(layer, 'path', attribs)\r
if not (vals[groups['70']][0] & 3) and len(vals[groups['10']]) == 3 and len(vals[groups['20']]) == 3:\r
path = 'M %f,%f Q %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][1], vals[groups['20']][1], vals[groups['10']][2], vals[groups['20']][2])\r
attribs = {'d': path, 'style': style}\r
- inkex.etree.SubElement(doc.getroot(), 'path', attribs)\r
+ inkex.etree.SubElement(layer, 'path', attribs)\r
\r
def export_CIRCLE():\r
# mandatory group codes : (10, 20, 40) (x, y, radius)\r
for i in range (1, len(vals[groups['10']])):\r
path += ' %f,%f' % (vals[groups['10']][i], vals[groups['20']][i])\r
attribs = {'d': path, 'style': style}\r
- inkex.etree.SubElement(doc.getroot(), 'path', attribs)\r
+ inkex.etree.SubElement(layer, 'path', attribs)\r
\r
def export_LWPOLYLINE():\r
# mandatory group codes : (10, 20, 70) (x, y, flags)\r
if vals[groups['70']][0] == 1: # closed path\r
path += ' z'\r
attribs = {'d': path, 'style': style}\r
- inkex.etree.SubElement(doc.getroot(), 'path', attribs)\r
+ inkex.etree.SubElement(layer, 'path', attribs)\r
\r
def generate_ellipse(xc, yc, xm, ym, w, a1, a2):\r
rm = math.sqrt(xm*xm + ym*ym)\r
else: # closed arc\r
path = 'M %f,%f A %f,%f %f 1 0 %f,%f %f,%f %f 1 0 %f,%f z' % (xc+xm, yc-ym, rm, w*rm, -180.0*a/math.pi, xc-xm, yc+ym, rm, w*rm, -180.0*a/math.pi, xc+xm, yc-ym)\r
attribs = {'d': path, 'style': style}\r
- inkex.etree.SubElement(doc.getroot(), 'path', attribs)\r
+ inkex.etree.SubElement(layer, 'path', attribs)\r
\r
def get_line():\r
return (stream.readline().strip(), stream.readline().strip())\r
ymax = 297.0 # default A4 height in mm\r
line = get_line()\r
flag = 0\r
-layers = {} # store colors by layer\r
+layer_colors = {} # store colors by layer\r
+layer_nodes = {} # store nodes by layer\r
while line[0] and line[1] != 'ENTITIES':\r
line = get_line()\r
if line[1] == '$EXTMIN':\r
if line[1] == '$EXTMAX':\r
xmax = get_group('10')\r
ymax = get_group('20')\r
- if line[0] == '2':\r
+ if flag and line[0] == '2':\r
name = line[1]\r
+ attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '%s' % name}\r
+ layer_nodes[name] = inkex.etree.SubElement(doc.getroot(), 'g', attribs)\r
if line[0] == '2' and line[1] == 'LAYER':\r
flag = 1\r
if flag and line[0] == '62':\r
- layers[name] = int(line[1])\r
+ layer_colors[name] = int(line[1])\r
if line[0] == '0' and line[1] == 'ENDTAB':\r
flag = 0\r
\r
if entities.has_key(entity):\r
color = '#000000' # default color\r
if vals[groups['8']]: # Common Layer Name\r
- if layers.has_key(vals[groups['8']][0]):\r
- if colors.has_key(layers[vals[groups['8']][0]]):\r
- color = colors[layers[vals[groups['8']][0]]]\r
+ layer = layer_nodes[vals[groups['8']][0]]\r
+ if layer_colors.has_key(vals[groups['8']][0]):\r
+ if colors.has_key(layer_colors[vals[groups['8']][0]]):\r
+ color = colors[layer_colors[vals[groups['8']][0]]]\r
if vals[groups['62']]: # Common Color Number\r
if colors.has_key(vals[groups['62']][0]):\r
color = colors[vals[groups['62']][0]]\r