CAD drawing of first example
Stefan Schuermans

Stefan Schuermans commited on 2013-05-20 11:05:52
Showing 4 changed files, with 262 additions and 21 deletions.

... ...
@@ -1 +1,3 @@
1
+.*.swp
2
+dxfngc.fo
1 3
 dxfngc.pdf
... ...
@@ -1,14 +1,22 @@
1 1
 NAME = dxfngc
2 2
 
3
+DB_DIR = /usr/share/xml/docbook
4
+DB_SCHEMA = $(DB_DIR)/schema/xsd/5.0/docbook.xsd
5
+DB_XSL_FO = $(DB_DIR)/stylesheet/docbook-xsl-ns/fo/docbook.xsl
6
+
3 7
 .PHONY: all clean
4 8
 .SUFFIXES:
5 9
 .SECONDARY:
6 10
 
7 11
 all: $(NAME).pdf
8 12
 
9
-%.pdf: %.xml
10
-	db2pdf $<
13
+%.fo: %.xml
14
+	xmlstarlet val --err --xsd $(DB_SCHEMA) $<
15
+	xsltproc $(DB_XSL_FO) $< >$@
16
+
17
+%.pdf: %.fo
18
+	fop -fo $< -pdf $@
11 19
 
12 20
 clean:
13
-	rm -f $(NAME).pdf
21
+	rm -f $(NAME).fo $(NAME).pdf
14 22
 
... ...
@@ -1,19 +1,19 @@
1
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
1
+<?xml version="1.0" encoding="utf-8"?>
2 2
 
3
-<article>
3
+<article xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
4 4
 
5 5
   <title>DXF to NGC Converter: dxfncg</title>
6 6
 
7 7
 
8
-  <sect1 id="introduction">
8
+  <sect1 xml:id="introduction">
9 9
 
10 10
     <title>Introduction</title>
11 11
 
12 12
     <para>
13 13
 
14
-      The DXF to NGC converter dxfngc provide a means to convert 2D technical
15
-      drawings in DXF file format to G-code in NGC format used by CNC mills
16
-      or routers (e.g. LinuxCNC).
14
+      The DXF to NGC converter <emphasis>dxfngc</emphasis> provides a
15
+      means to convert 2D technical drawings in DXF file format to G-code
16
+      in NGC format used by CNC mills or routers (e.g. LinuxCNC).
17 17
 
18 18
     </para>
19 19
 
... ...
@@ -21,36 +21,64 @@
21 21
 
22 22
       Usually, the 2D drawings in DXF format do not contain enough information
23 23
       for G-code creation, e.g. about which lines describe the border of a part
24
-      and which lines describe holes.  The diameter of the cutting tool and
25
-      the depth of the cut are other examples.  Therefore, dxfngc relies on
26
-      a script file to control the G-code generation.  This script is the input
27
-      to the tool.  It sets all the parameters and controls reading the drawing
28
-      and generation of the G-code.
24
+      and which lines describe holes.  The diameter of the cutting tool and the
25
+      depth of the cut are other examples.  Therefore, dxfngc relies on a
26
+      script file to control the G-code generation.  This script is the input
27
+      to the tool.  It sets all required parameters, reads the drawing,
28
+      controls generation of the G-code and finally writes the output file.
29 29
 
30 30
     </para>
31 31
 
32 32
   </sect1>
33 33
 
34
-  <sect1 id="first-example">
34
+  <sect1 xml:id="first_example">
35 35
 
36 36
     <title>A first example</title>
37 37
 
38 38
     <para>
39 39
 
40
-      To illustrate usage of dxfgnc, suppose a stencil for a logo shall be cut
41
-      with a CNC mill.  (TODO: image)  The basic shape of the stencil is a
42
-      circle.  The logo is formed by two holes with a specific shape.
40
+      To illustrate the usage of dxfngc, suppose a stencil for a logo shall be
41
+      cut with a CNC mill.  The basic shape of the stencil is a circle.  The
42
+      logo is formed by two holes with a specific shape (see <xref
43
+      linkend="logo_stencil"/>).
43 44
 
44 45
     </para>
45 46
 
47
+    <figure xml:id="logo_stencil">
48
+      <title>Logo Stencil</title>
49
+      <mediaobject>
50
+        <imageobject>
51
+          <imagedata fileref="logo_stencil.svg" format="SVG" width="30%"/>
52
+        </imageobject>
53
+      </mediaobject>
54
+      <caption>The logo stencil to be cut on the CNC mill.</caption>
55
+    </figure>
56
+
46 57
     <para>
47 58
 
48
-      First, the 2D drawing is created.  The circular border is drawn on
49
-      layer <parameter>border</parameter> and the two holes are drawn on layer
50
-      <parameter>holes</parameter>.
59
+      First, the 2D drawing is created with a CAD program in DXF format.  The
60
+      circular border is drawn on layer <parameter>border</parameter> and the
61
+      two holes are drawn on layer <parameter>holes</parameter> (see <xref
62
+      linkend="logo_drawing"/>).
51 63
 
52 64
     </para>
53 65
 
66
+    <figure xml:id="logo_drawing">
67
+      <title>Logo Drawing</title>
68
+      <mediaobject>
69
+        <imageobject>
70
+          <imagedata fileref="logo_drawing.svg" format="SVG" width="38%"/>
71
+        </imageobject>
72
+      </mediaobject>
73
+      <caption>The CAD drawing of the logo stencil.
74
+               Border and holes are on separate layers.</caption>
75
+    </figure>
76
+
77
+    <programlisting>
78
+foo();
79
+bar();
80
+    </programlisting>
81
+
54 82
   </sect1>
55 83
 
56 84
 </article>
... ...
@@ -0,0 +1,203 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+<svg
5
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+   xmlns:cc="http://creativecommons.org/ns#"
7
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
+   xmlns:svg="http://www.w3.org/2000/svg"
9
+   xmlns="http://www.w3.org/2000/svg"
10
+   xmlns:xlink="http://www.w3.org/1999/xlink"
11
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
13
+   width="1214.3242"
14
+   height="984"
15
+   id="svg2"
16
+   sodipodi:version="0.32"
17
+   inkscape:version="0.47 r22583"
18
+   sodipodi:docname="logo_drawing.svg"
19
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
20
+   version="1.0"
21
+   inkscape:export-filename="/home/efelon/projekte64/blinkenarea/logo/birne/logo_2_5_rgb.png"
22
+   inkscape:export-xdpi="110"
23
+   inkscape:export-ydpi="110">
24
+  <defs
25
+     id="defs4">
26
+    <linearGradient
27
+       id="linearGradient3943">
28
+      <stop
29
+         style="stop-color:#08aa00;stop-opacity:1;"
30
+         offset="0"
31
+         id="stop3945" />
32
+      <stop
33
+         style="stop-color:#08aa00;stop-opacity:0;"
34
+         offset="1"
35
+         id="stop3947" />
36
+    </linearGradient>
37
+    <inkscape:perspective
38
+       sodipodi:type="inkscape:persp3d"
39
+       inkscape:vp_x="0 : 526.18109 : 1"
40
+       inkscape:vp_y="0 : 1000 : 0"
41
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
42
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
43
+       id="perspective10" />
44
+    <inkscape:perspective
45
+       id="perspective2464"
46
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
47
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
48
+       inkscape:vp_y="0 : 1000 : 0"
49
+       inkscape:vp_x="0 : 526.18109 : 1"
50
+       sodipodi:type="inkscape:persp3d" />
51
+    <linearGradient
52
+       inkscape:collect="always"
53
+       xlink:href="#linearGradient3943"
54
+       id="linearGradient3949"
55
+       x1="281.24506"
56
+       y1="816.49463"
57
+       x2="459.64676"
58
+       y2="822.29108"
59
+       gradientUnits="userSpaceOnUse"
60
+       spreadMethod="pad"
61
+       gradientTransform="translate(-2.0844822,0)" />
62
+    <linearGradient
63
+       inkscape:collect="always"
64
+       xlink:href="#linearGradient3943"
65
+       id="linearGradient4026"
66
+       gradientUnits="userSpaceOnUse"
67
+       gradientTransform="translate(2.0844822,-115.1365)"
68
+       spreadMethod="pad"
69
+       x1="281.24506"
70
+       y1="816.49463"
71
+       x2="459.64676"
72
+       y2="822.29108" />
73
+    <inkscape:perspective
74
+       id="perspective3653"
75
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
76
+       inkscape:vp_z="1 : 0.5 : 1"
77
+       inkscape:vp_y="0 : 1000 : 0"
78
+       inkscape:vp_x="0 : 0.5 : 1"
79
+       sodipodi:type="inkscape:persp3d" />
80
+    <inkscape:perspective
81
+       id="perspective3653-1"
82
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
83
+       inkscape:vp_z="1 : 0.5 : 1"
84
+       inkscape:vp_y="0 : 1000 : 0"
85
+       inkscape:vp_x="0 : 0.5 : 1"
86
+       sodipodi:type="inkscape:persp3d" />
87
+    <inkscape:perspective
88
+       id="perspective3694"
89
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
90
+       inkscape:vp_z="1 : 0.5 : 1"
91
+       inkscape:vp_y="0 : 1000 : 0"
92
+       inkscape:vp_x="0 : 0.5 : 1"
93
+       sodipodi:type="inkscape:persp3d" />
94
+    <inkscape:perspective
95
+       id="perspective3694-1"
96
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
97
+       inkscape:vp_z="1 : 0.5 : 1"
98
+       inkscape:vp_y="0 : 1000 : 0"
99
+       inkscape:vp_x="0 : 0.5 : 1"
100
+       sodipodi:type="inkscape:persp3d" />
101
+    <inkscape:perspective
102
+       id="perspective3735"
103
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
104
+       inkscape:vp_z="1 : 0.5 : 1"
105
+       inkscape:vp_y="0 : 1000 : 0"
106
+       inkscape:vp_x="0 : 0.5 : 1"
107
+       sodipodi:type="inkscape:persp3d" />
108
+  </defs>
109
+  <sodipodi:namedview
110
+     id="base"
111
+     pagecolor="#ffffff"
112
+     bordercolor="#666666"
113
+     borderopacity="1.0"
114
+     inkscape:pageopacity="0.0"
115
+     inkscape:pageshadow="2"
116
+     inkscape:zoom="0.7195122"
117
+     inkscape:cx="607.16211"
118
+     inkscape:cy="492"
119
+     inkscape:document-units="px"
120
+     inkscape:current-layer="layer1"
121
+     showgrid="false"
122
+     inkscape:window-width="1279"
123
+     inkscape:window-height="960"
124
+     inkscape:window-x="0"
125
+     inkscape:window-y="25"
126
+     inkscape:snap-bbox="true"
127
+     inkscape:object-nodes="true"
128
+     inkscape:bbox-nodes="false"
129
+     inkscape:snap-nodes="true"
130
+     inkscape:snap-bbox-midpoints="true"
131
+     inkscape:snap-object-midpoints="true"
132
+     inkscape:window-maximized="0"
133
+     inkscape:snap-bbox-edge-midpoints="false" />
134
+  <metadata
135
+     id="metadata7">
136
+    <rdf:RDF>
137
+      <cc:Work
138
+         rdf:about="">
139
+        <dc:format>image/svg+xml</dc:format>
140
+        <dc:type
141
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
142
+        <dc:title></dc:title>
143
+      </cc:Work>
144
+    </rdf:RDF>
145
+  </metadata>
146
+  <g
147
+     inkscape:label="Ebene 1"
148
+     inkscape:groupmode="layer"
149
+     id="layer1"
150
+     style="display:inline"
151
+     transform="translate(132.45742,107.45162)">
152
+    <path
153
+       style="fill:none;stroke:#ff0000;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
154
+       d="m 372.04258,-105.95162 c -263.99312,0 -478,214.00823 -478,478 0,263.99177 214.00688,478 478,478 263.99312,0 478,-214.00823 478,-478 0,-263.99177 -214.00688,-478 -478,-478 z"
155
+       id="path2865" />
156
+    <path
157
+       style="fill:none;stroke:#007f00;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
158
+       d="m 184.35508,133.29838 375.40625,0 c 27.96943,0 51.03125,23.06182 51.03125,51.03125 l 0,375.40625 c 0,27.96943 -23.06182,51.03125 -51.03125,51.03125 l -193.75,0 -0.0937,0 -0.0625,0 c -12.76836,-0.12542 -25.86049,-5.52862 -35,-15.96875 -9.13951,-10.44013 -13.91189,-25.15896 -13.65625,-42.0625 0.46732,-32.04407 -0.25809,-49.55704 -3.3125,-60.09375 -3.05441,-10.53671 -8.02745,-16.88741 -22.125,-30.59375 -30.10152,-29.26619 -43.98316,-48.0574 -55.5625,-66.9375 -13.17453,-21.48104 -14.71799,-41.65847 -15.71875,-54.90625 l -0.0625,-0.65625 0,-0.65625 c 0,-84.03836 67.35997,-152.90625 150.34375,-152.90625 82.54642,0 149.6077,68.15876 150.3125,151.59375 5.3e-4,0.063 -4.6e-4,0.1245 0,0.1875 0.003,0.37917 0.0625,0.74521 0.0625,1.125 l -0.0312,0 c 0.22705,3.44774 1.44414,29.32132 -13.21875,55.59375 -13.2632,23.76451 -27.81938,41.41166 -60,68.40625 -15.26249,12.80288 -19.71675,17.75261 -22.21875,25.71875 -2.502,7.96614 -2.88115,23.31197 -2.28125,52.9375 a 17.50369,17.50369 0 1 1 -35,0.71875 c -0.60187,-29.7233 -1.36574,-47.33944 3.90625,-64.125 5.27199,-16.78556 16.78714,-28.38376 33.09375,-42.0625 30.63096,-25.69467 40.14906,-37.50289 51.9375,-58.625 9.95344,-17.83421 8.84375,-37.25 8.84375,-37.25 l -0.0312,-0.65625 0,-0.65625 c 0,-65.46016 -51.69436,-117.90625 -115.375,-117.90625 -63.48521,0 -114.99671,52.13314 -115.3125,117.3125 0.98368,13.08239 1.76301,24.13275 10.59375,38.53125 10.59232,17.27076 21.41363,32.24077 50.09375,60.125 15.29328,14.86889 26.17604,28.00279 31.375,45.9375 5.19896,17.93471 5.12998,37.85987 4.65625,70.34375 l 0,0.0312 c -0.15548,10.28022 2.49522,15.60753 5,18.46875 2.50478,2.86122 5.29601,3.99455 9.03125,4.03125 l 193.5625,0 c 9.18483,0 16.03125,-6.84642 16.03125,-16.03125 l 0,-375.40625 c 0,-9.18483 -6.84642,-16.03125 -16.03125,-16.03125 l -375.40625,0 c -9.18483,0 -16.03125,6.84642 -16.03125,16.03125 l 0,375.40625 c 0,9.18483 6.84642,16.03125 16.03125,16.03125 l 102.90625,0 a 17.50175,17.50175 0 1 1 0,35 l -102.90625,0 c -27.96943,0 -51.03125,-23.06182 -51.03125,-51.03125 l 0,-375.40625 c 0,-27.96943 23.06182,-51.03125 51.03125,-51.03125 z"
159
+       id="path2863" />
160
+    <path
161
+       style="fill:none;stroke:#007f00;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
162
+       d="m 348.32383,251.79838 a 15.82733,14.218759 0.00137158 0 1 15.5,10.1875 15.82733,14.218759 0.00137158 0 1 -7.84375,16.78125 c -18.54417,8.61856 -32.73298,23.17183 -39.875,40.84375 a 15.92123,14.303115 0.00137158 0 1 -29.78125,-10.125 c 9.79879,-24.24572 29.33881,-44.20668 54.78125,-56.03125 a 15.82733,14.218759 0.00137158 0 1 7.21875,-1.65625 z"
163
+       id="path3611" />
164
+    <path
165
+       style="font-size:36px;fill:none;stroke:#007f00;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
166
+       d="m 853.04255,-36.297307 96.99998,-9.99e-4"
167
+       id="path3639" />
168
+    <text
169
+       xml:space="preserve"
170
+       style="font-size:36px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;text-anchor:start;fill:#007f00;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
171
+       x="951.54254"
172
+       y="-22.876907"
173
+       id="text3641"><tspan
174
+         sodipodi:role="line"
175
+         id="tspan3643"
176
+         x="951.54254"
177
+         y="-22.876907"> holes</tspan></text>
178
+    <path
179
+       style="font-size:36px;fill:none;stroke:#ff0000;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
180
+       d="m 853.0426,-92.019959 96.99993,-9.99e-4"
181
+       id="path3639-9" />
182
+    <text
183
+       xml:space="preserve"
184
+       style="font-size:36px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;text-anchor:start;fill:#ff0000;fill-opacity:1;stroke:none;display:inline;font-family:Sans;-inkscape-font-specification:Sans"
185
+       x="951.54254"
186
+       y="-78.599564"
187
+       id="text3641-3"><tspan
188
+         sodipodi:role="line"
189
+         id="tspan3643-2"
190
+         x="951.54254"
191
+         y="-78.599564"> border</tspan></text>
192
+    <path
193
+       style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
194
+       d="m -80.95742,850.04834 -50,0"
195
+       id="path3756"
196
+       sodipodi:nodetypes="cc" />
197
+    <path
198
+       style="fill:none;stroke:#000000;stroke-width:2.99999976;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
199
+       d="m -105.95742,825.04832 0,50.00004"
200
+       id="path3758"
201
+       sodipodi:nodetypes="cc" />
202
+  </g>
203
+</svg>
0 204