1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
"""
This page is in the table of contents.
The feed script sets the maximum feed rate, operating feed rate & travel feed rate.
==Operation==
The default 'Activate Feed' checkbox is on. When it is on, the functions described below will work, when it is off, the functions will not be called.
==Settings==
===Feed Rate===
Default is 16 millimeters/second.
Defines the feed rate for the shape.
===Maximum Z Feed Rate===
If your firmware limits the z feed rate, you do not need to set these settings.
====Maximum Z Drill Feed Rate====
Default is 0.1 millimeters/second.
Defines the maximum feed that the tool head will move in the z direction while the tool is on.
====Maximum Z Travel Feed Rate====
Default is 8 millimeters/second.
Defines the maximum feed that the tool head will move in the z direction while the tool is off. The default of 8 millimeters per second is the maximum z feed of Nophead's direct drive z stage, the belt driven z stages have a lower maximum feed rate.
===Travel Feed Rate===
Default is 16 millimeters/second.
Defines the feed rate when the cutter is off. The travel feed rate could be set as high as the cutter can be moved, it does not have to be limited by the maximum cutter rate.
==Examples==
The following examples feed the file Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains Screw Holder Bottom.stl and feed.py.
> python feed.py
This brings up the feed dialog.
> python feed.py Screw Holder Bottom.stl
The feed tool is parsing the file:
Screw Holder Bottom.stl
..
The feed tool has created the file:
.. Screw Holder Bottom_feed.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 feed
>>> feed.main()
This brings up the feed dialog.
>>> feed.writeOutput( 'Screw Holder Bottom.stl' )
The feed tool is parsing the file:
Screw Holder Bottom.stl
..
The feed tool has created the file:
.. Screw Holder Bottom_feed.gcode
"""
from __future__ import absolute_import
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
from skeinforge_tools import analyze
from skeinforge_tools import profile
from skeinforge_tools.meta_plugins import polyfile
from skeinforge_tools.skeinforge_utilities import consecution
from skeinforge_tools.skeinforge_utilities import euclidean
from skeinforge_tools.skeinforge_utilities import gcodec
from skeinforge_tools.skeinforge_utilities import intercircle
from skeinforge_tools.skeinforge_utilities import interpret
from skeinforge_tools.skeinforge_utilities import settings
import math
import sys
__author__ = "Enrique Perez (perez_enrique@yahoo.com)"
__date__ = "$Date: 2008/21/04 $"
__license__ = "GPL 3.0"
def getCraftedText( fileName, text = '', feedRepository = None ):
"Feed the file or text."
return getCraftedTextFromText( gcodec.getTextIfEmpty( fileName, text ), feedRepository )
def getCraftedTextFromText( gcodeText, feedRepository = None ):
"Feed a gcode linear move text."
if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'feed' ):
return gcodeText
if feedRepository == None:
feedRepository = settings.getReadRepository( FeedRepository() )
if not feedRepository.activateFeed.value:
return gcodeText
return FeedSkein().getCraftedGcode( gcodeText, feedRepository )
def getNewRepository():
"Get the repository constructor."
return FeedRepository()
def writeOutput( fileName = '' ):
"Feed a gcode linear move file."
fileName = interpret.getFirstTranslatorFileNameUnmodified( fileName )
if fileName != '':
consecution.writeChainTextWithNounMessage( fileName, 'feed' )
class FeedRepository:
"A class to handle the feed settings."
def __init__( self ):
"Set the default settings, execute title & settings fileName."
profile.addListsToCraftTypeRepository( 'skeinforge_tools.craft_plugins.feed.html', self )
self.fileNameInput = settings.FileNameInput().getFromFileName( interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Feed', self, '' )
self.activateFeed = settings.BooleanSetting().getFromValue( 'Activate Feed:', self, True )
self.feedRatePerSecond = settings.FloatSpin().getFromValue( 2.0, 'Feed Rate (mm/s):', self, 50.0, 16.0 )
settings.LabelDisplay().getFromName( 'Maximum Z Feed Rate:', self )
self.maximumZDrillFeedRatePerSecond = settings.FloatSpin().getFromValue( 0.02, 'Maximum Z Drill Feed Rate (mm/s):', self, 0.5, 0.1 )
self.maximumZTravelFeedRatePerSecond = settings.FloatSpin().getFromValue( 0.5, 'Maximum Z Travel Feed Rate (mm/s):', self, 10.0, 8.0 )
self.travelFeedRatePerSecond = settings.FloatSpin().getFromValue( 2.0, 'Travel Feed Rate (mm/s):', self, 50.0, 16.0 )
self.executeTitle = 'Feed'
def execute( self ):
"Feed button has been clicked."
fileNames = polyfile.getFileOrDirectoryTypesUnmodifiedGcode( self.fileNameInput.value, interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled )
for fileName in fileNames:
writeOutput( fileName )
class FeedSkein:
"A class to feed a skein of cuttings."
def __init__( self ):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.feedRatePerSecond = 16.0
self.isExtruderActive = False
self.lineIndex = 0
self.lines = None
self.oldFlowrateString = None
self.oldLocation = None
def getCraftedGcode( self, gcodeText, feedRepository ):
"Parse gcode text and store the feed gcode."
self.distanceFeedRate.maximumZDrillFeedRatePerSecond = feedRepository.maximumZDrillFeedRatePerSecond.value
self.distanceFeedRate.maximumZTravelFeedRatePerSecond = feedRepository.maximumZTravelFeedRatePerSecond.value
self.feedRepository = feedRepository
self.feedRatePerSecond = feedRepository.feedRatePerSecond.value
self.travelFeedRatePerMinute = 60.0 * self.feedRepository.travelFeedRatePerSecond.value
self.lines = gcodec.getTextLines( gcodeText )
self.parseInitialization()
for line in self.lines[ self.lineIndex : ]:
self.parseLine( line )
return self.distanceFeedRate.output.getvalue()
def getFeededLine( self, splitLine ):
"Get gcode line with feed rate."
location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
self.oldLocation = location
feedRateMinute = 60.0 * self.feedRatePerSecond
if not self.isExtruderActive:
feedRateMinute = self.travelFeedRatePerMinute
return self.distanceFeedRate.getLinearGcodeMovementWithFeedRate( feedRateMinute, location.dropAxis( 2 ), location.z )
def parseInitialization( self ):
"Parse gcode initialization and store the parameters."
for self.lineIndex in xrange( len( self.lines ) ):
line = self.lines[ self.lineIndex ]
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
firstWord = gcodec.getFirstWord( splitLine )
self.distanceFeedRate.parseSplitLine( firstWord, splitLine )
if firstWord == '(</extruderInitialization>)':
self.distanceFeedRate.addLine( '(<procedureDone> feed </procedureDone>)' )
return
elif firstWord == '(<perimeterWidth>':
self.absolutePerimeterWidth = abs( float( splitLine[ 1 ] ) )
self.distanceFeedRate.addTagBracketedLine( 'maximumZDrillFeedRatePerSecond', self.distanceFeedRate.maximumZDrillFeedRatePerSecond )
self.distanceFeedRate.addTagBracketedLine( 'maximumZTravelFeedRatePerSecond', self.distanceFeedRate.maximumZTravelFeedRatePerSecond )
self.distanceFeedRate.addTagBracketedLine( 'operatingFeedRatePerSecond', self.feedRatePerSecond )
self.distanceFeedRate.addTagBracketedLine( 'travelFeedRatePerSecond', self.feedRepository.travelFeedRatePerSecond.value )
self.distanceFeedRate.addLine( line )
def parseLine( self, line ):
"Parse a gcode line and add it to the feed skein."
splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
if len( splitLine ) < 1:
return
firstWord = splitLine[ 0 ]
if firstWord == 'G1':
line = self.getFeededLine( splitLine )
elif firstWord == 'M101':
self.isExtruderActive = True
elif firstWord == 'M103':
self.isExtruderActive = False
self.distanceFeedRate.addLine( line )
def main():
"Display the feed dialog."
if len( sys.argv ) > 1:
writeOutput( ' '.join( sys.argv[ 1 : ] ) )
else:
settings.startMainLoopFromConstructor( getNewRepository() )
if __name__ == "__main__":
main()
|