1 """
2 This page is in the table of contents.
3 The svg.py script is an import translator plugin to get a carving from an svg file. This script will read an svg file made by skeinforge or by inkscape.
4
5 An example inkscape svg file is inkscape_star.svg in the models folder.
6
7 An import plugin is a script in the interpret_plugins folder which has the function getCarving. It is meant to be run from the interpret tool. To ensure that the plugin works on platforms which do not handle file capitalization properly, give the plugin a lower case name.
8
9 The getCarving function takes the file name of an svg file and returns the carving.
10
11 """
12
13 from fabmetheus_utilities.svg_reader import SVGReader
14 from fabmetheus_utilities.vector3 import Vector3
15 from fabmetheus_utilities import archive
16 from fabmetheus_utilities import euclidean
17 from fabmetheus_utilities import svg_writer
18 from fabmetheus_utilities import xml_simple_writer
19 import math
20
21
22 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
23 __credits__ = 'Nophead <http://hydraraptor.blogspot.com/>\nArt of Illusion <http://www.artofillusion.org/>'
24 __date__ = '$Date: 2008/21/04 $'
25 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
26
27
33
34
36 'An svg carving.'
38 'Add empty lists.'
39 self.layerThickness = 1.0
40 self.maximumZ = - 987654321.0
41 self.minimumZ = 987654321.0
42 self.svgReader = SVGReader()
43
45 'Get the string representation of this carving.'
46 return self.getCarvedSVG()
47
48 - def addXML(self, depth, output):
51
53 'Get the corner maximum of the vertexes.'
54 return self.cornerMaximum
55
57 'Get the corner minimum of the vertexes.'
58 return self.cornerMinimum
59
63
65 'Get the layer thickness.'
66 return self.layerThickness
67
69 'Get the rotated boundary layers.'
70 return self.svgReader.rotatedLoopLayers
71
73 'Return the fabmetheus XML.'
74 return None
75
77 'Return the suffix for a carving.'
78 return 'svg'
79
81 'Parse SVG text and store the layers.'
82 if svgText == '':
83 return
84 self.fileName = fileName
85 self.svgReader.parseSVG(fileName, svgText)
86 self.layerThickness = euclidean.getFloatDefaultByDictionary(
87 self.layerThickness, self.svgReader.sliceDictionary, 'layerThickness')
88 self.cornerMaximum = Vector3(-987654321.0, -987654321.0, self.maximumZ)
89 self.cornerMinimum = Vector3(987654321.0, 987654321.0, self.minimumZ)
90 svg_writer.setSVGCarvingCorners(
91 self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.svgReader.rotatedLoopLayers)
92
94 'Set the infill in direction of bridge.'
95 pass
96
98 'Set the layer thickness.'
99 self.layerThickness = layerThickness
100
102 'Set the import radius.'
103 pass
104
106 'Set the is correct mesh flag.'
107 pass
108