PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/skeinforge_application/skeinforge_plugins/craft_plugins/chamber.py

https://github.com/jmil/SFACT
Python | 241 lines | 209 code | 19 blank | 13 comment | 9 complexity | ef2f6d2fc135c1a9b37e556a2052233a MD5 | raw file
  1. """
  2. This page is in the table of contents.
  3. Some filaments contract too much and to prevent this you have to print the object in a temperature regulated chamber or on a temperature regulated bed. The chamber tool allows you to control the bed and chamber temperature and the holding pressure. The gcodes are also described at:
  4. http://reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
  5. The chamber manual page is at:
  6. http://fabmetheus.crsndoo.com/wiki/index.php/Skeinforge_Chamber
  7. ==Operation==
  8. The default 'Activate Chamber' checkbox is on. When it is on, the functions described below will work, when it is off, the functions will not be called.
  9. ==Settings==
  10. ===Bed Temperature===
  11. Default is 60C.
  12. Defines the print_bed temperature in Celcius by adding an M140 command.
  13. ===Chamber Temperature===
  14. Default is 30C.
  15. Defines the chamber temperature in Celcius by adding an M141 command.
  16. ===Holding Force===
  17. Default is zero.
  18. Defines the holding pressure of a mechanism, like a vacuum table or electromagnet, to hold the bed surface or object, by adding an M142 command. The holding pressure is in bar. For hardware which only has on/off holding, when the holding pressure is zero, turn off holding, when the holding pressure is greater than zero, turn on holding.
  19. ==Heated Beds==
  20. ===Bothacker===
  21. A resistor heated aluminum plate by Bothacker:
  22. http://bothacker.com
  23. with an article at:
  24. http://bothacker.com/2009/12/18/heated-build-platform/
  25. ===Domingo===
  26. A heated copper build plate by Domingo:
  27. http://casainho-emcrepstrap.blogspot.com/
  28. with articles at:
  29. http://casainho-emcrepstrap.blogspot.com/2010/01/first-time-with-pla-testing-it-also-on.html
  30. http://casainho-emcrepstrap.blogspot.com/2010/01/call-for-helpideas-to-develop-heated.html
  31. http://casainho-emcrepstrap.blogspot.com/2010/01/new-heated-build-platform.html
  32. http://casainho-emcrepstrap.blogspot.com/2010/01/no-acrylic-and-instead-kapton-tape-on.html
  33. http://casainho-emcrepstrap.blogspot.com/2010/01/problems-with-heated-build-platform-and.html
  34. http://casainho-emcrepstrap.blogspot.com/2010/01/perfect-build-platform.html
  35. http://casainho-emcrepstrap.blogspot.com/2009/12/almost-no-warp.html
  36. http://casainho-emcrepstrap.blogspot.com/2009/12/heated-base-plate.html
  37. ===Jmil===
  38. A heated build stage by jmil, over at:
  39. http://www.hive76.org
  40. with articles at:
  41. http://www.hive76.org/handling-hot-build-surfaces
  42. http://www.hive76.org/heated-build-stage-success
  43. ===Kulitorum===
  44. Kulitorum has made a heated bed. It is a 5mm Alu sheet with a pattern laid out in kapton tape. The wire is a 0.6mm2 Konstantin wire and it's held in place by small pieces of kapton tape. The description and picture is at:
  45. http://gallery.kulitorum.com/main.php?g2_itemId=283
  46. ===Metalab===
  47. A heated base by the Metalab folks:
  48. http://reprap.soup.io
  49. with information at:
  50. http://reprap.soup.io/?search=heated%20base
  51. ===Nophead===
  52. A resistor heated aluminum bed by Nophead:
  53. http://hydraraptor.blogspot.com
  54. with articles at:
  55. http://hydraraptor.blogspot.com/2010/01/will-it-stick.html
  56. http://hydraraptor.blogspot.com/2010/01/hot-metal-and-serendipity.html
  57. http://hydraraptor.blogspot.com/2010/01/new-year-new-plastic.html
  58. http://hydraraptor.blogspot.com/2010/01/hot-bed.html
  59. ===Prusajr===
  60. A resistive wire heated plexiglass plate by prusajr:
  61. http://prusadjs.cz/
  62. with articles at:
  63. http://prusadjs.cz/2010/01/heated-reprap-print-bed-mk2/
  64. http://prusadjs.cz/2009/11/look-ma-no-warping-heated-reprap-print-bed/
  65. ===Pumpernickel2===
  66. A resistor heated aluminum plate by Pumpernickel2:
  67. http://dev.forums.reprap.org/profile.php?14,844
  68. with a picture at:
  69. http://dev.forums.reprap.org/file.php?14,file=1228,filename=heatedplate.jpg
  70. ===Zaggo===
  71. A resistor heated aluminum plate by Zaggo at Pleasant Software:
  72. http://pleasantsoftware.com/developer/3d/
  73. with articles at:
  74. ttp://pleasantsoftware.com/developer/3d/2009/12/05/raftless/
  75. http://pleasantsoftware.com/developer/3d/2009/11/15/living-in-times-of-warp-free-printing/
  76. http://pleasantsoftware.com/developer/3d/2009/11/12/canned-heat/
  77. ==Examples==
  78. The following examples chamber the file Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains Screw Holder Bottom.stl and chamber.py.
  79. > python chamber.py
  80. This brings up the chamber dialog.
  81. > python chamber.py Screw Holder Bottom.stl
  82. The chamber tool is parsing the file:
  83. Screw Holder Bottom.stl
  84. ..
  85. The chamber tool has created the file:
  86. Screw Holder Bottom_chamber.gcode
  87. """
  88. from __future__ import absolute_import
  89. #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.
  90. import __init__
  91. from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
  92. from fabmetheus_utilities import archive
  93. from fabmetheus_utilities import euclidean
  94. from fabmetheus_utilities import gcodec
  95. from fabmetheus_utilities import settings
  96. from skeinforge_application.skeinforge_utilities import skeinforge_craft
  97. from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
  98. from skeinforge_application.skeinforge_utilities import skeinforge_profile
  99. import sys
  100. __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
  101. __date__ = '$Date: 2008/21/04 $'
  102. __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
  103. def getCraftedText(fileName, text='', repository=None):
  104. """Chamber the file or text."""
  105. return getCraftedTextFromText(archive.getTextIfEmpty(fileName, text), repository)
  106. def getCraftedTextFromText(gcodeText, repository=None):
  107. """Chamber a gcode linear move text."""
  108. if gcodec.isProcedureDoneOrFileIsEmpty( gcodeText, 'chamber'):
  109. return gcodeText
  110. if repository is None:
  111. repository = settings.getReadRepository(ChamberRepository())
  112. if not repository.activateChamber.value:
  113. return gcodeText
  114. return ChamberSkein().getCraftedGcode(gcodeText, repository)
  115. def getNewRepository():
  116. """Get new repository."""
  117. return ChamberRepository()
  118. def writeOutput(fileName, shouldAnalyze=True):
  119. """Chamber a gcode linear move file."""
  120. skeinforge_craft.writeChainTextWithNounMessage(fileName, 'chamber', shouldAnalyze)
  121. class ChamberRepository:
  122. """A class to handle the chamber settings."""
  123. def __init__(self):
  124. """Set the default settings, execute title & settings fileName."""
  125. skeinforge_profile.addListsToCraftTypeRepository('skeinforge_application.skeinforge_plugins.craft_plugins.chamber.html', self )
  126. self.fileNameInput = settings.FileNameInput().getFromFileName( fabmetheus_interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Chamber', self, '')
  127. self.openWikiManualHelpPage = settings.HelpPage().getOpenFromAbsolute('http://fabmetheus.crsndoo.com/wiki/index.php/Skeinforge_Chamber')
  128. self.activateChamber = settings.BooleanSetting().getFromValue('Activate Chamber..if you want below functions to work', self, False )
  129. settings.LabelSeparator().getFromRepository(self)
  130. self.BedHeaterTemperature = settings.FloatSpin().getFromValue( 20.0, 'Heated PrintBed Temperature (Celcius):', self, 130.0, 60.0 )
  131. settings.LabelSeparator().getFromRepository(self)
  132. self.turnBedHeaterOffAtShutDown = settings.BooleanSetting().getFromValue('Turn print Bed Heater Off at Shut Down', self, True )
  133. self.turnExtruderHeaterOffAtShutDown = settings.BooleanSetting().getFromValue('Turn Extruder Heater Off at Shut Down', self, True )
  134. self.executeTitle = 'Chamber'
  135. def execute(self):
  136. """"Chamber button has been clicked."""
  137. fileNames = skeinforge_polyfile.getFileOrDirectoryTypesUnmodifiedGcode(self.fileNameInput.value, fabmetheus_interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled)
  138. for fileName in fileNames:
  139. writeOutput(fileName)
  140. class ChamberSkein:
  141. """A class to chamber a skein of extrusions."""
  142. def __init__(self):
  143. self.distanceFeedRate = gcodec.DistanceFeedRate()
  144. self.lineIndex = 0
  145. self.lines = None
  146. def getCraftedGcode(self, gcodeText, repository):
  147. """Parse gcode text and store the chamber gcode."""
  148. self.repository = repository
  149. self.lines = archive.getTextLines(gcodeText)
  150. self.parseInitialization()
  151. for line in self.lines[self.lineIndex :]:
  152. self.parseLine(line)
  153. return self.distanceFeedRate.output.getvalue()
  154. def parseInitialization(self):
  155. """Parse gcode initialization and store the parameters."""
  156. for self.lineIndex in xrange(len(self.lines)):
  157. line = self.lines[self.lineIndex]
  158. splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
  159. firstWord = gcodec.getFirstWord(splitLine)
  160. self.distanceFeedRate.parseSplitLine(firstWord, splitLine)
  161. if firstWord == '(</extruderInitialization>)':
  162. self.distanceFeedRate.addLine('(<procedureName> chamber </procedureName>)')
  163. return
  164. self.distanceFeedRate.addLine(line)
  165. def parseLine(self, line):
  166. """Parse a gcode line and add it to the chamber skein."""
  167. splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
  168. if len(splitLine) < 1:
  169. return
  170. firstWord = splitLine[0]
  171. if firstWord == '(<crafting>)':
  172. self.distanceFeedRate.addLine(line)
  173. self.distanceFeedRate.addParameter('M140', self.repository.BedHeaterTemperature.value ) # Set bed temperature.
  174. elif firstWord == '(</crafting>)':
  175. self.distanceFeedRate.addLine(line)
  176. if self.repository.turnExtruderHeaterOffAtShutDown.value:
  177. self.distanceFeedRate.addLine('M104 S0') # Turn extruder heater off.
  178. if self.repository.turnBedHeaterOffAtShutDown.value:
  179. self.distanceFeedRate.addLine('M140 S0') # Turn bed heater off.
  180. return
  181. self.distanceFeedRate.addLine(line)
  182. def main():
  183. """Display the chamber dialog."""
  184. if len(sys.argv) > 1:
  185. writeOutput(' '.join(sys.argv[1 :]))
  186. else:
  187. settings.startMainLoopFromConstructor( getNewRepository() )
  188. if __name__ == "__main__":
  189. main()