Package plugins :: Module bottom
[hide private]
[frames] | no frames]

Source Code for Module plugins.bottom

 1  """ 
 2  Bottom sets the bottom of the carving to the defined altitude. Adjusts the Z heights of each layer. 
 3   
 4  Credits: 
 5          Original Author: Enrique Perez (http://skeinforge.com) 
 6          Contributors: Please see the documentation in Skeinforge  
 7          Modifed as SFACT: Ahmet Cem Turan (github.com/ahmetcemturan/SFACT)       
 8   
 9  License:  
10          GNU Affero General Public License http://www.gnu.org/licenses/agpl.html 
11  """ 
12   
13  from fabmetheus_utilities import archive 
14  import os, sys, time, math, logging 
15  from config import config 
16   
17  logger = logging.getLogger(__name__) 
18  name = __name__ 
19   
20 -def performAction(slicedModel):
21 "Align the model to the bottom of the printing plane" 22 if not config.getboolean(name, 'active'): 23 logger.info("%s plugin is not active", name.capitalize()) 24 return 25 BottomSkein(slicedModel).bottom()
26
27 -class BottomSkein:
28 "A class to bottom a skein of extrusions."
29 - def __init__(self, slicedModel):
30 self.slicedModel = slicedModel 31 self.additionalHeightRatio = config.getfloat(name, 'additional.height.ratio') 32 self.altitude = config.getfloat(name, 'altitude') 33 self.layerThickness = config.getfloat('carve', 'layer.height') 34 self.perimeterWidth = config.getfloat('carve', 'extrusion.width') 35 self.decimalPlaces = config.getint('general', 'decimal.places')
36
37 - def bottom(self):
38 "Parse svgText and store the bottom svgText." 39 40 fileName = self.slicedModel.runtimeParameters.inputFilename 41 svgText = self.slicedModel.svgText 42 43 rotatedLoopLayers = self.slicedModel.rotatedLoopLayers 44 45 zMinimum = 987654321.0 46 for rotatedLoopLayer in rotatedLoopLayers: 47 zMinimum = min(rotatedLoopLayer.z, zMinimum) 48 deltaZ = self.altitude + self.additionalHeightRatio * self.layerThickness - zMinimum 49 50 for rotatedLoopLayer in rotatedLoopLayers: 51 rotatedLoopLayer.z += deltaZ
52