1 from __future__ import absolute_import
3 import platform, os, subprocess, sys
5 from cura_sf.skeinforge_application.skeinforge_utilities import skeinforge_craft
6 from gui import profile
9 "Return the path to the pypy executable if we can find it. Else return False"
10 if platform.system() == "Windows":
12 pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/pypy.exe"));
15 pypyExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../pypy/bin/pypy"));
16 if os.path.exists(pypyExe):
19 path = os.environ['PATH']
20 paths = path.split(os.pathsep)
22 pypyExe = os.path.join(p, exeName)
23 if os.path.exists(pypyExe):
28 "Return the path to the pypy executable if we can find it. Else return False"
29 if platform.system() == "Windows":
30 exeName = "slic3r.exe"
31 slic3rExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../Slic3r/bin/slic3r.exe"));
34 slic3rExe = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../Slic3r/bin/slic3r"));
35 if os.path.exists(slic3rExe):
38 path = os.environ['PATH']
39 paths = path.split(os.pathsep)
41 slic3rExe = os.path.join(p, exeName)
42 if os.path.exists(slic3rExe):
46 def runSlice(fileNames):
47 "Run the slicer on the files. If we are running with PyPy then just do the slicing action. If we are running as Python, try to find pypy."
48 pypyExe = getPyPyExe()
49 for fileName in fileNames:
50 if platform.python_implementation() == "PyPy":
51 skeinforge_craft.writeOutput(fileName)
52 elif pypyExe == False:
53 print "************************************************"
54 print "* Failed to find pypy, so slicing with python! *"
55 print "************************************************"
56 skeinforge_craft.writeOutput(fileName)
57 print "************************************************"
58 print "* Failed to find pypy, so sliced with python! *"
59 print "************************************************"
61 subprocess.call([pypyExe, os.path.join(sys.path[0], sys.argv[0]), fileName])
63 def getSliceCommand(filename):
64 if profile.getPreference('slicer').startswith('Slic3r'):
65 slic3rExe = getSlic3rExe()
66 if slic3rExe == False:
69 '--output-filename-format', '[input_filename_base]_export.gcode',
70 '--nozzle-diameter', str(profile.calculateEdgeWidth()),
71 '--print-center', '%s,%s' % (profile.getProfileSetting('machine_center_x'), profile.getProfileSetting('machine_center_y')),
73 '--gcode-flavor', 'reprap',
75 '--filament-diameter', profile.getProfileSetting('filament_diameter'),
76 '--extrusion-multiplier', str(1.0 / float(profile.getProfileSetting('filament_density'))),
77 '--temperature', profile.getProfileSetting('print_temperature'),
78 '--travel-speed', profile.getProfileSetting('travel_speed'),
79 '--perimeter-speed', profile.getProfileSetting('print_speed'),
80 '--small-perimeter-speed', profile.getProfileSetting('print_speed'),
81 '--infill-speed', profile.getProfileSetting('print_speed'),
82 '--solid-infill-speed', profile.getProfileSetting('print_speed'),
83 '--bridge-speed', profile.getProfileSetting('print_speed'),
84 '--bottom-layer-speed-ratio', str(float(profile.getProfileSetting('bottom_layer_speed')) / float(profile.getProfileSetting('print_speed'))),
85 '--layer-height', profile.getProfileSetting('layer_height'),
86 '--first-layer-height-ratio', '1.0',
87 '--infill-every-layers', '1',
88 '--perimeters', str(profile.calculateLineCount()),
89 '--solid-layers', str(profile.calculateSolidLayerCount()),
90 '--fill-density', str(float(profile.getProfileSetting('fill_density'))/100),
92 '--fill-pattern', 'rectilinear',
93 '--solid-fill-pattern', 'rectilinear',
94 '--start-gcode', profile.getAlterationFilePath('start.gcode'),
95 '--end-gcode', profile.getAlterationFilePath('end.gcode'),
96 '--retract-length', profile.getProfileSetting('retraction_amount'),
97 '--retract-speed', str(int(float(profile.getProfileSetting('retraction_speed')))),
98 '--retract-restart-extra', profile.getProfileSetting('retraction_extra'),
99 '--retract-before-travel', profile.getProfileSetting('retraction_min_travel'),
100 '--retract-lift', '0',
101 '--slowdown-below-layer-time', profile.getProfileSetting('cool_min_layer_time'),
102 '--min-print-speed', profile.getProfileSetting('cool_min_feedrate'),
103 '--skirts', profile.getProfileSetting('skirt_line_count'),
104 '--skirt-distance', str(int(float(profile.getProfileSetting('skirt_gap')))),
105 '--skirt-height', '1',
106 '--scale', profile.getProfileSetting('model_scale'),
107 '--rotate', profile.getProfileSetting('model_rotate_base'),
108 '--duplicate-x', profile.getProfileSetting('model_multiply_x'),
109 '--duplicate-y', profile.getProfileSetting('model_multiply_y'),
110 '--duplicate-distance', '10']
111 if profile.getProfileSetting('support') != 'None':
112 cmd.extend(['--support-material'])
113 cmd.extend([filename])
116 pypyExe = getPyPyExe()
118 pypyExe = sys.executable
119 return [pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), filename]