First cura integration attempt
This commit is contained in:
parent
c24a66c361
commit
281ad0f046
7 changed files with 1683 additions and 0 deletions
1
octoprint/cura/.__init__.py
Normal file
1
octoprint/cura/.__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
''
|
||||
45
octoprint/cura/cura.py
Normal file
45
octoprint/cura/cura.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
__author__ = "Ross Hendrickson savorywatt"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
class CuraWrapper(object):
|
||||
|
||||
CURA_PATH = '/home/rosshendrickson/workspaces/opensource/CuraEngine/CuraEngine'
|
||||
|
||||
@staticmethod
|
||||
def create_slicer(path=None):
|
||||
|
||||
if path:
|
||||
return CuraEngine(path)
|
||||
else:
|
||||
return CuraEngine(CuraWrapper.CURA_PATH)
|
||||
|
||||
|
||||
|
||||
class CuraEngine(object):
|
||||
|
||||
def __init__(self, cura_path):
|
||||
|
||||
|
||||
self.cura_path = cura_path
|
||||
|
||||
logging.info('CuraEngine Created')
|
||||
|
||||
|
||||
def process_file(self, config, gcode, file_path):
|
||||
"""Wraps around the main.cpp processFile method.
|
||||
|
||||
:param config: :class: `string` :path to a cura config file:
|
||||
:param gcode: :class: `string :path to write out the gcode generated:
|
||||
:param file_path: :class: `string :path to the STL to be sliced:
|
||||
|
||||
:note This just uses subprocess at the moment.
|
||||
"""
|
||||
|
||||
args = [self.cura_path, '-s', config, '-o', gcode, file_path]
|
||||
logging.info('CuraEngine args:%s' % str(args))
|
||||
|
||||
process = subprocess.call(args)
|
||||
logging.info('CuraEngine Exit:%s' % str(process))
|
||||
11
octoprint/cura/ev
Normal file
11
octoprint/cura/ev
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
;Generated with Cura_SteamEngine 1.0
|
||||
M107
|
||||
M104 S0 ;extruder heater off
|
||||
M140 S0 ;heated bed heater off (if you have it)
|
||||
G91 ;relative positioning
|
||||
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
|
||||
G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more
|
||||
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
|
||||
M84 ;steppers off
|
||||
G90 ;absolute positioning
|
||||
|
||||
0
octoprint/cura/tests/.__init__.py
Normal file
0
octoprint/cura/tests/.__init__.py
Normal file
BIN
octoprint/cura/tests/.test_cura.py.swp
Normal file
BIN
octoprint/cura/tests/.test_cura.py.swp
Normal file
Binary file not shown.
1598
octoprint/cura/tests/test.stl
Normal file
1598
octoprint/cura/tests/test.stl
Normal file
File diff suppressed because it is too large
Load diff
28
octoprint/cura/tests/test_cura.py
Normal file
28
octoprint/cura/tests/test_cura.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
|
||||
import unittest
|
||||
|
||||
from cura import CuraWrapper
|
||||
from cura import CuraEngine
|
||||
|
||||
class CuraWrapperTestCase(unittest.TestCase):
|
||||
|
||||
|
||||
def test_cura_wrapper(self):
|
||||
|
||||
fake_path = 'my/temp/path'
|
||||
result = CuraWrapper.create_slicer(fake_path)
|
||||
|
||||
self.assertEqual(fake_path, result.cura_path)
|
||||
|
||||
def test_cura_engine_process_file(self):
|
||||
|
||||
cura_engine = CuraWrapper.create_slicer()
|
||||
|
||||
file_path = '/cura/tests/test.stl'
|
||||
config_path = '/cura/tests/config'
|
||||
gcode_filename= 'output.gcode'
|
||||
|
||||
cura_engine.process_file(config_path, gcode_filename, file_path)
|
||||
|
||||
|
||||
Loading…
Reference in a new issue