Python: module skeinforge_application.skeinforge_plugins.craft_plugins.stretch

skeinforge_application.skeinforge_plugins.craft_plugins.stretch ($Date: 2008/21/04 $) | index /home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/stretch.py

Previous / Next / Contents

`
Stretch is very important Skeinforge plugin that allows you to partially compensate for the fact that extruded holes are smaller then they should be. It stretches the threads to partially compensate for filament shrinkage when extruded.
The stretch manual page is at:
http://fabmetheus.crsndoo.com/wiki/index.php/Skeinforge_Stretch
Extruded holes are smaller than the model because while printing an arc the head is depositing filament on both sides of the arc but in the inside of the arc you actually need less material then on the outside of the arc. You can read more about this on the RepRap ArcCompensation page:
http://reprap.org/bin/view/Main/ArcCompensation
In general, stretch will widen holes and push corners out. In practice the filament contraction will not be identical to 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.
All the defaults assume that the thread sequence choice setting in fill is the edge 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 edge.
Holes should be made with the correct area for their radius. In other words, for example if your modeling program approximates a hole of radius one (area = pi) by making a square with the points at [(1,0), (0,1), (-1,0), (0,-1)] (area = 2), the radius should be increased by sqrt(pi/2). This can be done in fabmetheus xml by writing:
radiusAreal='True'
in the attributes of the object or any parent of that object. In other modeling programs, you'll have to this manually or make a script. If area compensation is not done, then changing the stretch parameters to over compensate for too small hole areas will lead to incorrect compensation in other shapes.
Operation
Settings
Loop Stretch Over Perimeter Width
Path Stretch Over Perimeter Width
Perimeter
Perimeter Inside Stretch Over Perimeter Width
Perimeter Outside Stretch Over Perimeter Width
Stretch from Distance over Perimeter Width
Examples
`

## Operation

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.

## Settings

### Loop Stretch Over Perimeter Width

Default is 0.1.
Defines the ratio of the maximum amount the loop aka inner shell threads will be stretched compared to the edge width, in general this value should be the same as the 'Perimeter Outside Stretch Over Perimeter Width' setting.

### Path Stretch Over Perimeter Width

Default is zero.
Defines the ratio of the maximum amount the threads which are not loops, like the infill threads, will be stretched compared to the edge width.

### Perimeter

#### Perimeter Inside Stretch Over Perimeter Width

Default is 0.32.
Defines the ratio of the maximum amount the inside edge thread will be stretched compared to the edge width, this is the most important setting in stretch. The higher the value the more it will stretch the edge 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.

#### Perimeter Outside Stretch Over Perimeter Width

Default is 0.1.
Defines the ratio of the maximum amount the outside edge thread will be stretched compared to the edge width, in general this value should be around a third of the 'Perimeter Inside Stretch Over Perimeter Width' setting.

### Stretch from Distance over Perimeter Width

Default is two.
The stretch 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' times the edge width, on both sides, and moves the thread in the opposite direction. So it takes the current turning-point, goes "Stretch from Distance over Perimeter Width" * "Perimeter Width" ahead, reads the direction at that point. Then it goes the same distance in back in time, reads the direction at that other point. It then moves the thread in the opposite direction, away from the center of the arc formed by these 2 points+directions.
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.

## Examples

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

Previous / Next / Contents

Modules

``

__init__ fabmetheus_utilities.archive fabmetheus_utilities.euclidean | fabmetheus_utilities.fabmetheus_tools.fabmetheus_interpret fabmetheus_utilities.gcodec fabmetheus_utilities.intercircle | fabmetheus_utilities.settings skeinforge_application.skeinforge_utilities.skeinforge_craft skeinforge_application.skeinforge_utilities.skeinforge_polyfile | skeinforge_application.skeinforge_utilities.skeinforge_profile 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 settings. `

Methods defined here:

__init__(self)
  `Set the default settings, execute title & settings fileName.`

execute(self)
  `Stretch button has been clicked.`

class StretchSkein
`` | `A class to stretch a skein of extrusions. `

Methods defined here:

__init__(self)

getCraftedGcode(self, gcodeText, stretchRepository)
  `Parse gcode text and store the stretch gcode.`

getCrossLimitedStretch(self, crossLimitedStretch, crossLineIterator, locationComplex)
  `Get cross limited relative stretch for a location.`

getRelativeStretch(self, locationComplex, lineIterator)
  `Get relative stretch for a location.`

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.`

setStretchToPath(self)
  `Set the thread stretch to path stretch and is loop false.`

Functions

``

getCraftedText(fileName, gcodeText, stretchRepository=None)
  `Stretch a gcode linear move text.`

getCraftedTextFromText(gcodeText, stretchRepository=None)
  `Stretch a gcode linear move text.`

getNewRepository()
  `Get new repository.`

main()
  `Display the stretch dialog.`

writeOutput(fileName, shouldAnalyze=True)
  `Stretch a gcode linear move file. Chain stretch the gcode if it is not already stretched.`

Data
`` |  | __author__ = 'Enrique Perez (perez_enrique@yahoo.com)' __date__ = '$Date: 2008/21/04 $' __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

Author
`` |  | Enrique Perez (perez_enrique@yahoo.com)