forked from Joshua-Nti/Topography_Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_10config.py
More file actions
306 lines (245 loc) · 10.7 KB
/
_10config.py
File metadata and controls
306 lines (245 loc) · 10.7 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# _10config.py
import os
import platform
# ---------------------------------------------------------------------------
# OS DETECTION
# ---------------------------------------------------------------------------
def get_system_name():
"""
Returns human-readable platform identifier:
- 'Darwin' for macOS
- 'Windows' for Windows
- 'Linux' for Linux
"""
return platform.system()
# ---------------------------------------------------------------------------
# EXTERNAL BINARIES (SuperSlicer / Slic3r)
# ---------------------------------------------------------------------------
def get_superslicer_binary():
"""
Returns path to SuperSlicer (used for slicing STL -> GCODE).
PLEASE ADJUST the Windows path to your install location.
"""
system_name = get_system_name()
if system_name == "Darwin": # macOS
return "/Applications/SuperSlicer.app/Contents/MacOS/SuperSlicer"
if system_name == "Windows":
# EXAMPLE. Change this to where SuperSlicer.exe actually lives:
return r"C:\Program Files\SuperSlicer\superslicer.exe"
# fallback for Linux or custom env in PATH
return "superslicer"
def get_slic3r_binary():
"""
Returns path to Slic3r / SuperSlicer console for --cut operations.
This is used in _02cutstl.py.
PLEASE ADJUST the Windows path to the console slicer you use.
"""
system_name = get_system_name()
if system_name == "Darwin":
# Example for a local Slic3r bundle shipped with the project
return "/Applications/Slic3r.app/Contents/MacOS/Slic3r"
if system_name == "Windows":
# EXAMPLE. Update this to your slic3r-console.exe or superslicer_console.exe:
return r"C:\Program Files\Slic3r\Slic3r-console.exe"
# fallback
return "slic3r"
# ---------------------------------------------------------------------------
# PROJECT FOLDER LAYOUT
# ---------------------------------------------------------------------------
def make_folder_dict(base_name):
"""
Returns dictionary with all working/output subfolders for a given part root.
Example base_name: 'test' for test.stl.
We do NOT create them here, only describe them.
"""
root_dir = base_name # we keep folder name equal to base name
return {
"root": os.path.join(root_dir),
"stl_parts": os.path.join(root_dir, "stl_parts"),
"stl_tf": os.path.join(root_dir, "stl_tf"),
"tf_surfaces": os.path.join(root_dir, "tf_surfaces"),
"gcode_tf": os.path.join(root_dir, "gcode_tf"),
"gcode_parts": os.path.join(root_dir, "gcode_parts"),
}
# ---------------------------------------------------------------------------
# GEOMETRY / BACKTRANSFORM / QUALITY CONTROL SETTINGS
# ---------------------------------------------------------------------------
# Everything here is used by refineMesh, transformGCode, slowdown logic, etc.
GEOMETRY_CONFIG = {
# How finely we refine STL triangles before applying the nonplanar transform.
# This gets passed to refineMesh(stl, maxlength=...).
"refine_edge_length_mm": 1.0,
# Max XY length [mm] of each linear toolpath subsegment after subdivision
# during backtransform. Smaller = more accurate following of surface,
# but more G-code.
"maximal_segment_length_mm": 0.6,
# Angle tolerance [deg] for detecting downward-facing triangles.
# Triangles whose normal is within this angle of -Z (downwards) are "critical".
"downward_angle_deg": 10.0,
# Feedrate [mm/min] for perimeters above downward-facing regions.
# We inject F<slow_feedrate> once when entering the slow zone.
"slow_feedrate_mm_per_min": 180.0,
"medium_feedrate_mm_per_min": 400.0,
# Minimal allowed Z after backtransform. This clamps the toolpath upward
# to avoid diving below a desired safety plane.
"z_desired_min_mm": 6.0,
# XY shift applied during backtransform in transformGCode().
# (In practice you were using +90/+90.)
"xy_backtransform_shift_mm": (90.0, 90.0),
}
# ---------------------------------------------------------------------------
# CUTTING SETTINGS (used by _02cutstl.py)
# ---------------------------------------------------------------------------
CUT_CONFIG = {
# We ignore cut planes at or below this height (e.g. 0.0)
"ignore_cuts_at_or_below_mm": 0.0,
# Whether we sort cuts from low to high.
"sort_cuts_ascending": True,
}
# ---------------------------------------------------------------------------
# SLICER SETTINGS / SUPER SLICER ARGUMENTS
# ---------------------------------------------------------------------------
# Everything that controls how execSlicer builds its command.
SLICER_CONFIG = {
# Path to your slicer profile. You can also make this absolute if needed.
"config_ini_path": "config.ini",
# Arguments that always apply (before any special bottom/top/transformed tuning).
"base_args": [
"-g",
"--dont-arrange",
"--loglevel=1",
# NOTE: we will insert ["--load", config_ini_path] dynamically in execSlicer
],
# Normal (not-first-layer-special) parts default tuning.
"standard_part_args": [
"--skirts", "0",
"--disable-fan-first-layers", "0",
"--first-layer-extrusion-width", "0",
"--bottom-solid-layers", "0",
"--top-solid-layers", "2",
"--infill-first",
"--no-ensure-on-bed",
"--start-gcode", "G1 E{retract_length[0]} F1800",
],
# Bottom part settings (first printed segment).
"bottom_part_args": {
"support_material": False,
"start_gcode_multiline": (
"G90 ; use absolute coordinates\n"
"M83 ; extruder relative mode\n"
"M104 S[first_layer_temperature] ; set extruder temp\n"
"M140 S[first_layer_bed_temperature] ; set bed temp\n"
"M190 S[first_layer_bed_temperature] ; wait for bed temp\n"
"M109 S[first_layer_temperature] ; wait for extruder temp\n"
"G28 W ; home all without mesh bed level\n"
"G80 ; mesh bed leveling\n"
"{if filament_settings_id[initial_tool]=~/.*Prusament PA11.*/}\n"
"G1 Z0.3 F720\n"
"G1 Y-3 F1000 ; go outside print area\n"
"G92 E0\n"
"G1 X60 E9 F1000 ; intro line\n"
"G1 X100 E9 F1000 ; intro line\n"
"{else}\n"
"G1 Z0.2 F720\n"
"G1 Y-3 F1000 ; go outside print area\n"
"G92 E0\n"
"G1 X60 E9 F1000 ; intro line\n"
"G1 X100 E12.5 F1000 ; intro line\n"
"{endif}\n"
"G92 E0\n"
"M221 S{if layer_height<0.075}100{else}95{endif}\n"
"; Do not change E values below. Excessive value can damage the printer.\n"
"{if print_settings_id=~/.*(DETAIL @MK3|QUALITY @MK3).*/}"
"M907 E430 ; set extruder motor current{endif}\n"
"{if print_settings_id=~/.*(SPEED @MK3|DRAFT @MK3).*/}"
"M907 E538 ; set extruder motor current{endif}"
),
},
# Top part settings (last printed segment).
"top_part_args": {
"end_gcode_multiline": (
"{if max_layer_z < max_print_height}"
"G1 Z{z_offset+min(max_layer_z+49, max_print_height)} F720 ; Move head up"
"{endif}\n"
"G4 ; wait\n"
"M221 S100 ; reset flow\n"
"M900 K0 ; reset LA\n"
"{if print_settings_id=~/.*(DETAIL @MK3|QUALITY @MK3|@0.25 nozzle MK3).*/}"
"M907 E538 ; reset extruder motor current"
"{endif}\n"
"M104 S0 ; turn off temperature\n"
"M140 S0 ; turn off heatbed\n"
"M107 ; fan off\n"
"M84 ; disable motors\n"
"; max_layer_z = [max_layer_z]"
),
},
# Tuning for transformed (nonplanar) parts.
"transformed_extra_args": [
# "--external-perimeter-speed", "8",
"--bridge-flow-ratio", "0.5",
"--extrusion-width", "0.3",
"--perimeter-extrusion-width", "0.3",
"--external-perimeter-extrusion-width", "0.3",
"--infill-extrusion-width", "0.3",
"--solid-infill-extrusion-width", "0.3",
"--top-infill-extrusion-width", "0.3",
"--perimeters", "4",
"--extrusion-multiplier", "1.0",
"--solid-infill-below-area", "0",
"--bottom-solid-layers", "1",
"--top-solid-min-thickness", "0",
"--bottom-solid-min-thickness", "0",
"--extra-perimeters-overhangs",
],
# Default behavior for parts that are NOT top parts:
"default_top_solid_layers": 1,
"default_end_gcode": "",
}
# ---------------------------------------------------------------------------
# ANALYSE STL SETTINGS (for _01analysestl.py)
# ---------------------------------------------------------------------------
ANALYSE_STL = {
"input_stl": "Test.stl",
# 1. Overhang detection
# A face is considered “downward” if its normal vector is within this
# angle (degrees) of the -Z axis.
"overhang_angle_deg": 15.0,
# 2. Bridge span threshold in XY (mm)
# Clusters of downward-facing triangles wider than this are considered
# serious overhangs or large bridges and will trigger their own segment.
"bridge_span_mm_min": 6.0,
# 3. Vertical offset for cut (mm)
# How far BELOW the first unsupported Z we place the cutting plane.
"cut_below_mm": 1.0,
# 4. Minimum distance (mm) between two cuts
# If multiple cut candidates are closer than this, we keep only the LOWER one.
"min_segment_height_mm": 4.0,
# 5. Maximum vertical height (mm) allowed for a single nonplanar segment
# Segments flagged as transform=1 will be subdivided internally if taller.
"max_transform_segment_height_mm": 5.0,
# Optional: toggle for visualization in standalone mode
"show_debug_plot": False,
}
# ---------------------------------------------------------------------------
# PIPELINE CONFIG (global behavior of _00all.py)
# ---------------------------------------------------------------------------
PIPELINE_CONFIG = {
# Whether to run transformGCode() also for planar parts with no tf_surface.
"apply_backtransform_to_planar": False,
# Whether to apply final XY shift to merged G-code via moveGCode().
"apply_final_shift": True,
# Where to drop the final toolpath on the build plate.
# This is used by _08movegcode.py at the very end.
"final_shift_xy_mm": (100.0, 100.0),
# Markers that tell moveGCode() when the "real part" starts,
# so purge/intro lines are not shifted.
"move_start_markers": [
";layer:",
"; layer ",
";begin layer",
"; printing",
],
# Keep a copy of the STL in the working root and cut that copy.
"copy_input_to_work": True,
}