summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: deb5d4d)
raw | patch | inline | side by side (parent: deb5d4d)
author | acspike <acspike@users.sourceforge.net> | |
Sun, 9 Mar 2008 19:06:03 +0000 (19:06 +0000) | ||
committer | acspike <acspike@users.sourceforge.net> | |
Sun, 9 Mar 2008 19:06:03 +0000 (19:06 +0000) |
made a few changes from his patch. converted dxf_outlines.dxf in to a
python module with strings because looping over lines in the DXF file
looked fragile. We need get someone to test this with RoboMaster to
make sure the output still works properly.
python module with strings because looping over lines in the DXF file
looked fragile. We need get someone to test this with RoboMaster to
make sure the output still works properly.
share/extensions/Makefile.am | patch | blob | history | |
share/extensions/dxf_outlines.py | patch | blob | history | |
share/extensions/dxf_templates.py | [new file with mode: 0644] | patch | blob |
index c17b4bfa725b73908ac299a40d80af6789caaed4..026fe010c7251eb9ec115118a791534d8698de24 100644 (file)
dimension.py \
dots.py \
dxf_outlines.py \
+ dxf_templates.py \
edge3d.py \
embedimage.py \
embed_raster_in_svg.pl \
index 6cb4e1eaacbddd33c9250abf39bd155d6607c589..2e20af56d47db0aa47065f4fc4a41acf37c3d856 100755 (executable)
#!/usr/bin/env python
'''
-Copyright (C) 2005,2007 Aaron Spike, aaron@ekips.org
+Copyright (C) 2005,2007,2008 Aaron Spike, aaron@ekips.org
+Copyright (C) 2008 Alvin Penner, penner@vaxxine.com
+
+- template dxf_outlines.dxf added Feb 2008 by Alvin Penner, penner@vaxxine.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
-import inkex, simplepath, cubicsuperpath
+import inkex, simplepath, cubicsuperpath, dxf_templates
class MyEffect(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.dxf = ''
+ self.handle = 255 # initiallize handle for DXF ENTITY
def output(self):
print self.dxf
def dxf_add(self, str):
self.dxf += str
def dxf_line(self,csp):
- line = "\n0\nLINE\n8\n2\n62\n4\n10\n%f\n20\n%f\n30\n0\n11\n%f\n21\n%f\n31\n0" % (csp[0][0],csp[0][1],csp[1][0],csp[1][1])
- self.dxf_add(line)
+ self.dxf_add(" 0\nLINE\n 5\n%x\n100\nAcDbEntity\n 8\n0\n100\nAcDbLine\n" % self.handle)
+ self.dxf_add(" 10\n%f\n 20\n%f\n 30\n0.0\n 11\n%f\n 21\n%f\n 31\n0.0\n" % (csp[0][0],csp[0][1],csp[1][0],csp[1][1]))
def dxf_spline(self,csp):
knots = 8
ctrls = 4
- self.dxf_add("\n 0\nSPLINE\n 5\n43\n 8\n0\n 62\n256\n370\n-1\n 6\nByLayer")
- self.dxf_add("\n100\nAcDbEntity\n100\nAcDbSpline\n 70\n8\n 71\n3\n 72\n%d\n 73\n%d\n 74\n0" % (knots, ctrls))
+ self.dxf_add(" 0\nSPLINE\n 5\n%x\n100\nAcDbEntity\n 8\n0\n100\nAcDbSpline\n" % self.handle)
+ self.dxf_add(" 70\n8\n 71\n3\n 72\n%d\n 73\n%d\n 74\n0\n" % (knots, ctrls))
for i in range(2):
for j in range(4):
- self.dxf_add("\n 40\n%d" % i)
+ self.dxf_add(" 40\n%d\n" % i)
for i in csp:
- self.dxf_add("\n 10\n%f\n 20\n%f\n 30\n0" % (i[0],i[1]))
+ self.dxf_add(" 10\n%f\n 20\n%f\n 30\n0.0\n" % (i[0],i[1]))
def effect(self):
#References: Minimum Requirements for Creating a DXF File of a 3D Model By Paul Bourke
# NURB Curves: A Guide for the Uninitiated By Philip J. Schneider
- self.dxf_add("999\nDXF created by Inkscape\n0\nSECTION\n2\nENTITIES")\r
- \r
+ self.dxf_add("999\nDXF created by Inkscape\n")
+ self.dxf_add(dxf_templates.r14_header)
+
scale = 25.4/90.0
- h = inkex.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0])\r
-
+ h = inkex.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0])
path = '//svg:path'
- for node in self.document.getroot().xpath(path, namespaces=inkex.NSS):\r
- d = node.get('d')\r
- sim = simplepath.parsePath(d)\r
- simplepath.scalePath(sim,scale,-scale)\r
+ for node in self.document.getroot().xpath(path, namespaces=inkex.NSS):
+ d = node.get('d')
+ sim = simplepath.parsePath(d)
+ simplepath.scalePath(sim,scale,-scale)
simplepath.translatePath(sim,0,h*scale)
p = cubicsuperpath.CubicSuperPath(sim)
for sub in p:
for i in range(len(sub)-1):
+ # generate unique handle for DXF ENTITY
+ self.handle += 1
s = sub[i]
e = sub[i+1]
if s[1] == s[2] and e[0] == e[1]:
self.dxf_line([s[1],e[1]])
else:
self.dxf_spline([s[1],s[2],e[0],e[1]])
- self.dxf_add("\n0\nENDSEC\n0\nEOF\n")
+ self.dxf_add(dxf_templates.r14_footer)
e = MyEffect()
e.affect()
diff --git a/share/extensions/dxf_templates.py b/share/extensions/dxf_templates.py
--- /dev/null
@@ -0,0 +1,639 @@
+r14_header = ''' 0\r
+SECTION\r
+ 2\r
+HEADER\r
+ 9\r
+$ACADVER\r
+ 1\r
+AC1014\r
+ 9\r
+$HANDSEED\r
+ 5\r
+FFFF\r
+ 0\r
+ENDSEC\r
+ 0\r
+SECTION\r
+ 2\r
+TABLES\r
+ 0\r
+TABLE\r
+ 2\r
+VPORT\r
+ 5\r
+8\r
+330\r
+0\r
+100\r
+AcDbSymbolTable\r
+ 70\r
+ 4\r
+ 0\r
+VPORT\r
+ 5\r
+2E\r
+330\r
+8\r
+100\r
+AcDbSymbolTableRecord\r
+100\r
+AcDbViewportTableRecord\r
+ 2\r
+*ACTIVE\r
+ 70\r
+ 0\r
+ 10\r
+0.0\r
+ 20\r
+0.0\r
+ 11\r
+1.0\r
+ 21\r
+1.0\r
+ 12\r
+4.25\r
+ 22\r
+5.5\r
+ 13\r
+0.0\r
+ 23\r
+0.0\r
+ 14\r
+10.0\r
+ 24\r
+10.0\r
+ 15\r
+10.0\r
+ 25\r
+10.0\r
+ 16\r
+0.0\r
+ 26\r
+0.0\r
+ 36\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ecord\r
+100\r
+AcDbLayerTableRecord\r
+ 2\r
+0\r
+ 70\r
+ 0\r
+ 62\r
+ 7\r
+ 6\r
+CONTINUOUS\r
+ 0\r
+ENDTAB\r
+ 0\r
+TABLE\r
+ 2\r
+STYLE\r
+ 5\r
+3\r
+330\r
+0\r
+100\r
+AcDbSymbolTable\r
+ 70\r
+ 1\r
+ 0\r
+STYLE\r
+ 5\r
+11\r
+330\r
+3\r
+100\r
+AcDbSymbolTableRecord\r
+100\r
+AcDbTextStyleTableRecord\r
+ 2\r
+STANDARD\r
+ 70\r
+ 0\r
+ 40\r
+0.0\r
+ 41\r
+1.0\r
+ 50\r
+0.0\r
+ 71\r
+ 0\r
+ 42\r
+2.5\r
+ 3\r
+txt\r
+ 4\r
+\r
+ 0\r
+ENDTAB\r
+ 0\r
+TABLE\r
+ 2\r
+VIEW\r
+ 5\r
+6\r
+330\r
+0\r
+100\r
+AcDbSymbolTable\r
+ 70\r
+ 0\r
+ 0\r
+ENDTAB\r
+ 0\r
+TABLE\r
+ 2\r
+UCS\r
+ 5\r
+7\r
+330\r
+0\r
+100\r
+AcDbSymbolTable\r
+ 70\r
+ 0\r
+ 0\r
+ENDTAB\r
+ 0\r
+TABLE\r
+ 2\r
+APPID\r
+ 5\r
+9\r
+330\r
+0\r
+100\r
+AcDbSymbolTable\r
+ 70\r
+ 2\r
+ 0\r
+APPID\r
+ 5\r
+12\r
+330\r
+9\r
+100\r
+AcDbSymbolTableRecord\r
+100\r
+AcDbRegAppTableRecord\r
+ 2\r
+ACAD\r
+ 70\r
+ 0\r
+ 0\r
+ENDTAB\r
+ 0\r
+TABLE\r
+ 2\r
+DIMSTYLE\r
+ 5\r
+A\r
+330\r
+0\r
+100\r
+AcDbSymbolTable\r
+ 70\r
+ 1\r
+ 0\r
+DIMSTYLE\r
+105\r
+27\r
+330\r
+A\r
+100\r
+AcDbSymbolTableRecord\r
+100\r
+AcDbDimStyleTableRecord\r
+ 2\r
+ISO-25\r
+ 70\r
+ 0\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+ENDTAB\r
+ 0\r
+ENDSEC\r
+ 0\r
+SECTION\r
+ 2\r
+BLOCKS\r
+ 0\r
+BLOCK\r
+ 5\r
+20\r
+330\r
+1F\r
+100\r
+AcDbEntity\r
+ 8\r
+0\r
+100\r
+AcDbBlockBegin\r
+ 2\r
+*MODEL_SPACE\r
+ 70\r
+ 0\r
+ 10\r
+0.0\r
+ 20\r
+0.0\r
+ 30\r
+0.0\r
+ 3\r
+*MODEL_SPACE\r
+ 1\r
+\r
+ 0\r
+ENDBLK\r
+ 5\r
+21\r
+330\r
+1F\r
+100\r
+AcDbEntity\r
+ 8\r
+0\r
+100\r
+AcDbBlockEnd\r
+ 0\r
+BLOCK\r
+ 5\r
+1C\r
+330\r
+1B\r
+100\r
+AcDbEntity\r
+ 67\r
+ 1\r
+ 8\r
+0\r
+100\r
+AcDbBlockBegin\r
+ 2\r
+*PAPER_SPACE\r
+ 1\r
+\r
+ 0\r
+ENDBLK\r
+ 5\r
+1D\r
+330\r
+1B\r
+100\r
+AcDbEntity\r
+ 67\r
+ 1\r
+ 8\r
+0\r
+100\r
+AcDbBlockEnd\r
+ 0\r
+ENDSEC\r
+ 0\r
+SECTION\r
+ 2\r
+'''\r
+\r
+\r
+r14_footer = '''OBJECTS\r
+ 0\r
+DICTIONARY\r
+ 5\r
+C\r
+330\r
+0\r
+100\r
+AcDbDictionary\r
+ 3\r
+ACAD_GROUP\r
+350\r
+D\r
+ 3\r
+ACAD_MLINESTYLE\r
+350\r
+17\r
+ 0\r
+DICTIONARY\r
+ 5\r
+D\r
+330\r
+C\r
+100\r
+AcDbDictionary\r
+ 0\r
+DICTIONARY\r
+ 5\r
+1A\r
+330\r
+C\r
+100\r
+AcDbDictionary\r
+ 0\r
+DICTIONARY\r
+ 5\r
+17\r
+330\r
+C\r
+100\r
+AcDbDictionary\r
+ 3\r
+STANDARD\r
+350\r
+18\r
+ 0\r
+DICTIONARY\r
+ 5\r
+19\r
+330\r
+C\r
+100\r
+AcDbDictionary\r
+ 0\r
+ENDSEC\r
+ 0\r
+EOF'''\r