summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 119b87d)
raw | patch | inline | side by side (parent: 119b87d)
author | alvinpenner <alvinpenner@users.sourceforge.net> | |
Sun, 30 Nov 2008 00:29:21 +0000 (00:29 +0000) | ||
committer | alvinpenner <alvinpenner@users.sourceforge.net> | |
Sun, 30 Nov 2008 00:29:21 +0000 (00:29 +0000) |
share/extensions/dxf_input.py | patch | blob | history |
index 603cc94abdc803bf84ef868e7783188c1b8d6968..235c777b0748e5a90282c9475721fa22d3495d22 100644 (file)
size = 12 # default fontsize in px\r
if vals[groups['40']]:\r
size = scale*vals[groups['40']][0]\r
- attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %dpx; stroke: %s' % (size, color)}\r
+ attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %dpx; fill: %s' % (size, color)}\r
angle = 0 # default angle in degrees\r
if vals[groups['50']]:\r
angle = vals[groups['50']][0]\r
# define DXF Entities and specify which Group Codes to monitor\r
\r
entities = {'MTEXT': export_MTEXT, 'TEXT': export_MTEXT, 'POINT': export_POINT, 'LINE': export_LINE, 'SPLINE': export_SPLINE, 'CIRCLE': export_CIRCLE, 'ARC': export_ARC, 'ELLIPSE': export_ELLIPSE, 'LEADER': export_LEADER, 'LWPOLYLINE': export_LWPOLYLINE, 'ENDSEC': ''}\r
-groups = {'1': 0, '10': 1, '11': 2, '20': 3, '21': 4, '40': 5, '41': 6, '42': 7, '50': 8, '51': 9, '62': 10, '70': 11, '370': 12}\r
-colors = {1: '#FF0000', 2: '#FFFF00', 3: '#00FF00', 4: '#00FFFF', 5: '#0000FF', 6: '#FF00FF', 7: '#FFFFFF', 8: '#414141', 9: '#808080'}\r
+groups = {'1': 0, '8': 1, '10': 2, '11': 3, '20': 4, '21': 5, '40': 6, '41': 7, '42': 8, '50': 9, '51': 10, '62': 11, '70': 12, '370': 13}\r
+colors = { 1: '#FF0000', 2: '#FFFF00', 3: '#00FF00', 4: '#00FFFF', 5: '#0000FF',\r
+ 6: '#FF00FF', 8: '#414141', 9: '#808080', 30: '#FF7F00',\r
+ 250: '#333333', 251: '#505050', 252: '#696969', 253: '#828282', 254: '#BEBEBE', 255: '#FFFFFF'}\r
\r
doc = inkex.etree.parse(StringIO('<svg xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"></svg>'))\r
stream = open(inkex.sys.argv[1], 'r')\r
xmax = xmin = 0.0\r
ymax = 297.0 # default A4 height in mm\r
line = get_line()\r
+flag = 0\r
+layers = {} # store colors 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
+ name = line[1]\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
+ if line[0] == '0' and line[1] == 'ENDTAB':\r
+ flag = 0\r
\r
scale = 90.0/25.4 # default convert from mm to pixels\r
if xmax > xmin:\r
line = get_line()\r
if entity and groups.has_key(line[0]):\r
seqs.append(line[0]) # list of group codes\r
- if line[0] == '1': # text value\r
+ if line[0] == '1' or line[0] == '8': # text value\r
val = line[1].replace('\~', ' ')\r
elif line[0] == '62' or line[0] == '70': # unscaled integer value\r
val = int(line[1])\r
elif entities.has_key(line[1]):\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
if vals[groups['62']]: # Common Color Number\r
if colors.has_key(vals[groups['62']][0]):\r
color = colors[vals[groups['62']][0]]\r
style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none', 'stroke-width': '%.1f' % w})\r
entities[entity]()\r
entity = line[1]\r
- vals = [[],[],[],[],[],[],[],[],[],[],[],[],[]]\r
+ vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[]]\r
seqs = []\r
\r
doc.write(inkex.sys.stdout)\r