skeinforge_tools.craft_plugins.stretch ($Date: 2008/21/04 $)
index
/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/craft_plugins/stretch.py

Stretch is a script to stretch the threads to partially compensate for filament shrinkage when extruded.

The default 'Activate Stretch' checkbox is off. When it is on, the functions described below will work, when it is off, the functions will not be called.

The important value for the stretch preferences is "Perimeter Inside Stretch Over Perimeter Width" which is the ratio of the maximum amount the inside perimeter thread will be stretched compared to the perimeter width, the default is 0.32. The higher the value the more it will stretch the perimeter and the wider holes will be. If the value is too small, the holes could be drilled out after fabrication, if the value is too high, the holes would be too wide and the part would have to junked. The 'Perimeter Outside Stretch Over Perimeter Width' is the ratio of the maximum amount the outside perimeter thread will be stretched compared to the perimeter width, in general this value should be around a third of the 'Perimeter Inside Stretch Over Perimeter Width' preference. The 'Loop Stretch Over Perimeter Width' is the ratio of the maximum amount the loop aka inner shell threads will be stretched compared to the perimeter width, in general this value should be the same as the 'Perimeter Outside Stretch Over Perimeter Width' preference. The 'Path Stretch Over Perimeter Width' is the ratio of the maximum amount the threads which are not loops, like the infill threads, will be stretched compared to the perimeter width, the default is 0.

All these defaults assume that the thread sequence choice preference in fill is the perimeter being extruded first, then the loops, then the infill. If the thread sequence choice is different, the optimal thread parameters will also be different. In general, if the infill is extruded first, the infill would have to be stretched more so that even after the filament shrinkage, it would still be long enough to connect to the loop or perimeter.

In general, stretch will widen holes and push corners out. The algorithm works by checking at each turning point on the extrusion path what the direction of the thread is at a distance of "Stretch from Distance over Perimeter Width (ratio)" times the perimeter width, on both sides, and moves the thread in the opposite direction. The magnitude of the stretch increases with the amount that the direction of the two threads is similar and by the Stretch Over Perimeter Width ratio. The script then also stretches the thread at two locations on the path on close to the turning points. In practice the filament contraction will be similar but different from the algorithm, so even once the optimal parameters are determined, the stretch script will not be able to eliminate the inaccuracies caused by contraction, but it should reduce them.

The following examples stretch the file Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains Screw Holder Bottom.stl and stretch.py.


> python stretch.py
This brings up the stretch dialog.


> python stretch.py Screw Holder Bottom.stl
The stretch tool is parsing the file:
Screw Holder Bottom.stl
..
The stretch tool has created the file:
.. Screw Holder Bottom_stretch.gcode


> python
Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import stretch
>>> stretch.main()
This brings up the stretch dialog.


>>> stretch.writeOutput()
The stretch tool is parsing the file:
Screw Holder Bottom.stl
..
The stretch tool has created the file:
.. Screw Holder Bottom_stretch.gcode

 
Modules
       
__init__
skeinforge_tools.skeinforge_utilities.consecution
skeinforge_tools.skeinforge_utilities.euclidean
skeinforge_tools.skeinforge_utilities.gcodec
skeinforge_tools.skeinforge_utilities.intercircle
skeinforge_tools.skeinforge_utilities.interpret
skeinforge_tools.meta_plugins.polyfile
skeinforge_tools.skeinforge_utilities.preferences
sys

 
Classes
       
LineIteratorBackward
LineIteratorForward
StretchRepository
StretchSkein

 
class LineIteratorBackward
    Backward line iterator class.
 
  Methods defined here:
__init__(self, isLoop, lineIndex, lines)
getIndexBeforeNextDeactivate(self)
Get index two lines before the deactivate command.
getNext(self)
Get next line going backward or raise exception.
isBeforeExtrusion(self)
Determine if index is two or more before activate command.

 
class LineIteratorForward
    Forward line iterator class.
 
  Methods defined here:
__init__(self, isLoop, lineIndex, lines)
getIndexJustAfterActivate(self)
Get index just after the activate command.
getNext(self)
Get next line or raise exception.

 
class StretchRepository
    A class to handle the stretch preferences.
 
  Methods defined here:
__init__(self)
Set the default preferences, execute title & preferences fileName.
execute(self)
Stretch button has been clicked.

 
class StretchSkein
    A class to stretch a skein of extrusions.
 
  Methods defined here:
__init__(self)
addAlongWayLine(self, alongWay, location)
Add stretched gcode line, along the way from the location to the old location.
addStretchesBeforePoint(self, location)
Get stretched gcode line.
getCraftedGcode(self, gcodeText, stretchRepository)
Parse gcode text and store the stretch gcode.
getIsThreadWiddershins(self)
Determine if the thread is widdershins.
getRelativeStretch(self, location, lineIndexRange)
Get relative stretch for a location minus a point.
getStretchedLine(self, splitLine)
Get stretched gcode line.
getStretchedLineFromIndexLocation(self, indexPreviousStart, indexNextStart, location)
Get stretched gcode line from line index and location.
isJustBeforeExtrusion(self)
Determine if activate command is before linear move command.
parseInitialization(self)
Parse gcode initialization and store the parameters.
parseStretch(self, line)
Parse a gcode line and add it to the stretch skein.

 
Functions
       
getCraftedText(fileName, text, stretchRepository=None)
Stretch a gcode linear move text.
getCraftedTextFromText(gcodeText, stretchRepository=None)
Stretch a gcode linear move text.
getRepositoryConstructor()
Get the repository constructor.
main()
Display the stretch dialog.
writeOutput(fileName='')
Stretch a gcode linear move file.  Chain stretch the gcode if it is not already stretched.  If no fileName is specified, stretch the first unmodified gcode file in this folder.

 
Data
        __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
__date__ = '$Date: 2008/21/04 $'
__license__ = 'GPL 3.0'
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

 
Author
        Enrique Perez (perez_enrique@yahoo.com)