chiark / gitweb /
Fix script for new filenames and fix a bug that made it use only one profile per...
[cura.git] / scripts / create_lulzbot_profiles.py
1 #!/usr/bin/python
2 #
3 # This script is used to generate print profiles for lulzbot printers
4 # based off of the lulzbot_profiles directory which contains common
5 # profiles for multiple toolheads.
6 # To generate profiles or update them, make sure there are no existing profiles
7 # by doing a rm -rf resources/quickprint/lulzbot_mini* resources/quickprint/lulzbot_TAZ*
8 # then run the script from the root Cura directory with ./scripts/create_lulzbot_profiles.py
9 #
10
11
12 import glob
13 import os
14 import sys
15
16
17 CURA_QUICKPRINT_DIR="resources/quickprint/"
18 PROFILES_DIR="lulzbot_profiles"
19
20 dir_map = {
21     'Mini_single_extruder_v2': ('lulzbot_mini',),
22     'Mini_flexystruder_v2': ('lulzbot_mini_flexystruder',),
23     'TAZ_single_extruder_0.35nozzle': ('lulzbot_TAZ_4_SingleV1',
24                                        'lulzbot_TAZ_5_SingleV1',
25                                        'lulzbot_TAZ_4_035nozzle',
26                                        'lulzbot_TAZ_5_035nozzle'),
27     'TAZ_single_extruder_0.5nozzle': ('lulzbot_TAZ_4_05nozzle',
28                                       'lulzbot_TAZ_5_05nozzle'),
29     'TAZ_dual_extruder_v1': ('lulzbot_TAZ_4_DualV1',
30                              'lulzbot_TAZ_5_DualV1'),
31     'TAZ_dual_extruder_v2': ('lulzbot_TAZ_4_DualV2',
32                              'lulzbot_TAZ_5_DualV2'),
33     'TAZ_flexystruder_v1': ('lulzbot_TAZ_4_FlexystruderV1',
34                             'lulzbot_TAZ_5_FlexystruderV1'),
35     'TAZ_flexystruder_v2': ('lulzbot_TAZ_4_FlexystruderV2',
36                             'lulzbot_TAZ_5_FlexystruderV2'),
37     'TAZ_flexy_dually_v1': ('lulzbot_TAZ_4_FlexyDuallyV1',
38                             'lulzbot_TAZ_5_FlexyDuallyV1'),
39     'TAZ_flexy_dually_v2': ('lulzbot_TAZ_4_FlexyDuallyV2',
40                             'lulzbot_TAZ_5_FlexyDuallyV2'),
41 }
42
43 material_map = {
44     # Beginner
45     "HIPS_eSUN": "HIPS",
46     "PLA_eSUN": "PLA",
47     "PLA_VP": "PLA",
48     # Intermediate
49     "ABS_VP": "ABS",
50     "Laybrick" : "laybrick",
51     "PP-Iron": "protopasta-magnetic-iron",
52     "PP-Steel": "protopasta-stainless-steel",
53     # Advanced
54     "Alloy910": "alloy910",
55     "Bridge": "bridge",
56     "Laywood": "laywood",
57     "n-vent": "n-vent",
58     "PCTPE": "PCTPE",
59     "PC-ABS": "PC-ABS",
60     "T-Glase": "t-glase",
61     # Expert
62     "PP-Conductive": "protopasta-conductive-PLA",
63     "HIPS_VP" : "HIPS",
64     "PC_VP": "polycarbonate",
65     "618-Nylon": "618-645-nylon",
66     "645-Nylon": "618-645-nylon",
67     # Dual extruder (Expert)
68     'PLA_PVA': 'PLA-PVA-support',
69     'ABS_ABS': 'ABS-ABS',
70     'PLA_PLA': 'PLA-PLA',
71     # Flexystruder (Expert)
72     "ninjaflex" : "ninjaflex",
73     "semiflex" : "semiflex",
74     # Flexy Dually (Expert)
75     "ABS_ninjaflex" : "ABS-ninjaflex",
76     "ABS_semiflex" : "ABS-semiflex",
77
78     # Others
79     # bamboofill
80     # b-pet
81     # bronzefill
82     # copperfill
83     # tritan
84     # PLA-protopasta-conductive-PLA
85 }
86
87 material_order = {
88     # Beginner
89     "HIPS_eSUN": 0,
90     "PLA_eSUN": 1,
91     "PLA_VP": 2,
92     # Intermediate
93     "ABS_VP": 10,
94     "Laybrick" : 11,
95     "PP-Iron": 12,
96     "PP-Steel": 13,
97     # Advanced
98     "Alloy910": 50,
99     "Bridge": 51,
100     "Laywood": 52,
101     "n-vent": 53,
102     "PCTPE": 54,
103     "PC-ABS": 55,
104     "T-Glase": 56,
105     # Expert
106     "PP-Conductive": 500,
107     "HIPS_VP" : 501,
108     "PC_VP": 502,
109     "618-Nylon": 503,
110     "645-Nylon": 504,
111     # Dual extruder (Expert)
112     'PLA_PVA': 2,
113     'ABS_ABS': 1,
114     'PLA_PLA': 0,
115     # Flexystruder (Expert)
116     "ninjaflex" : 0,
117     "semiflex" : 1,
118     # Flexy Dually (Expert)
119     "ABS_ninjaflex" : 0,
120     "ABS_semiflex" : 1,
121 }
122
123 material_types = {
124     # Beginner
125     "HIPS_eSUN": "Beginner",
126     "PLA_eSUN": "Beginner",
127     "PLA_VP": "Beginner",
128     # Intermediate
129     "ABS_VP": "Intermediate",
130     "Laybrick" : "Intermediate",
131     "PP-Iron": "Intermediate",
132     "PP-Steel": "Intermediate",
133     # Advanced
134     "Alloy910": "Advanced",
135     "Bridge": "Advanced",
136     "Laywood": "Advanced",
137     "n-vent": "Advanced",
138     "PCTPE": "Advanced",
139     "PC-ABS": "Advanced",
140     "T-Glase": "Advanced",
141     # Expert
142     "PP-Conductive": "Expert",
143     "HIPS_VP" : "Expert",
144     "PC_VP": "Expert",
145     "618-Nylon": "Expert",
146     "645-Nylon": "Expert",
147     # Dual extruder (Expert)
148     'PLA_PVA': "Expert",
149     'ABS_ABS': "Expert",
150     'PLA_PLA': "Expert",
151     # Flexystruder (Expert)
152     "ninjaflex" : "Expert",
153     "semiflex" : "Expert",
154     # Flexy Dually (Expert)
155     "ABS_ninjaflex" : "Expert",
156     "ABS_semiflex" : "Expert",
157 }
158
159 material_names = {
160     # Beginner
161     "HIPS_eSUN": "HIPS (eSUN)",
162     "PLA_eSUN": "PLA (eSUN)",
163     "PLA_VP": "PLA (Village Plastics)",
164     # Intermediate
165     "ABS_VP": "ABS (Village Plastics)",
166     "Laybrick" : "Laybrick (CC-Products)",
167     "PP-Iron": "Iron PLA (Proto-pasta)",
168     "PP-Steel": "Steel PLA (Proto-pasta)",
169     # Advanced
170     "Alloy910": "Alloy 910 (Taulman)",
171     "Bridge": "Bridge Nylon (Taulman)",
172     "Laywood": "Laywoo-D3 (CC-Products)",
173     "n-vent": "n-vent (Taulman)",
174     "PCTPE": "PCTPE (Taulman)",
175     "PC-ABS": "PC-ABS (Proto-pasta",
176     "T-Glase": "t-glase (Taulman)",
177     # Expert
178     "PP-Conductive": "Conductive (Proto-pasta)",
179     "HIPS_VP" : "HIPS (Village Plastics)",
180     "PC_VP": "PC (Village Plastics)",
181     "618-Nylon": "618 Nylon (Taulman)",
182     "645-Nylon": "645 Nylon (Taulman)",
183     # Dual extruder (Expert)
184     'PLA_PVA': "PLA & PVA",
185     'ABS_ABS': "ABS & ABS",
186     'PLA_PLA': "ABS & ABS",
187     # Flexystruder (Expert)
188     "ninjaflex" : "NinjaFlex (Fenner Drives)",
189     "semiflex" : "SemiFlex (Fenner Drives)",
190     # Flexy Dually (Expert)
191     "ABS_ninjaflex" : "ABS & NinjaFlex",
192     "ABS_semiflex" : "ABS & SemiFlex",
193 }
194
195 material_url = {
196     # Beginner
197     "HIPS_eSUN": "https://www.lulzbot.com/products/hips-3mm-filament-1kg-reel-esun",
198     "PLA_eSUN": "https://www.lulzbot.com/products/pla-3mm-filament-1kg-or-500g-reel-esun",
199     "PLA_VP": "https://www.lulzbot.com/products/pla-3mm-filament-1kg-reel-village-plastics",
200     # Intermediate
201     "ABS_VP": "https://www.lulzbot.com/products/abs-3mm-filament-1kg-reel",
202     "Laybrick" : "https://www.lulzbot.com/products/laybrick-filament-3mm",
203     "PP-Iron": "https://www.lulzbot.com/products/magnetic-iron-pla-3mm-filament-500g-reel-proto-pasta",
204     "PP-Steel": "https://www.lulzbot.com/products/stainless-steel-pla-3mm-filament-500g-reel-proto-pasta",
205     # Advanced
206     "Alloy910": "https://www.lulzbot.com/products/alloy-910-3mm-filament-1lb-reel-taulman",
207     "Bridge": "https://www.lulzbot.com/products/taulman-bridge-nylon-3mm-filament-1-pound",
208     "Laywood": "https://www.lulzbot.com/products/laywoo-d3-cherry-laywood-3mm-250g-coil-cc-products",
209     "n-vent": "https://www.lulzbot.com/products/n-vent-3mm-filament-1lb-taulman",
210     "PCTPE": "https://www.lulzbot.com/products/taulman-pctpe-3mm-filament-1-pound",
211     "PC-ABS": "https://www.lulzbot.com/products/pc-abs-alloy-3mm-filament-500g-reel-proto-pasta",
212     "T-Glase": "https://www.lulzbot.com/products/t-glase-3mm-filament-1lb-reel",
213     # Expert
214     "PP-Conductive": "https://www.lulzbot.com/products/conductive-pla-3mm-filament-500g-reel-proto-pasta",
215     "HIPS_VP" : "https://www.lulzbot.com/products/hips-3mm-filament-1kg-or-5lb-reel-village-plastics",
216     "PC_VP": "https://www.lulzbot.com/products/polycarbonate-3mm-filament-1kg-reel",
217     "618-Nylon": "https://www.lulzbot.com/products/taulman-618-nylon-3mm-filament-1-pound",
218     "645-Nylon": "https://www.lulzbot.com/products/taulman-645-nylon-3mm-filament-1-pound",
219     # Dual extruder (Expert)
220     'ABS_ABS': "https://www.lulzbot.com/products/abs-3mm-filament-1kg-reel",
221     'PLA_PLA': "https://www.lulzbot.com/products/pla-3mm-filament-1kg-or-500g-reel-esun",
222     'PLA_PVA': "https://www.lulzbot.com/products/natural-pva-3mm-filament-05kg-reel-esun",
223     # Flexystruder (Expert)
224     "ninjaflex" : "https://www.lulzbot.com/ninjaflex",
225     "semiflex" : "https://www.lulzbot.com/products/semiflex-tpe-thermoplastic-elastomer-3mm-075kg",
226     # Flexy Dually (Expert)
227     "ABS_ninjaflex" : "https://www.lulzbot.com/ninjaflex",
228     "ABS_semiflex" : "https://www.lulzbot.com/products/semiflex-tpe-thermoplastic-elastomer-3mm-075kg",
229 }
230
231 profile_map = {
232     'medium-quality': 'Standard',
233     'high-speed': 'High Speed',
234     'high-quality': 'High Detail',
235     'high-clarity': 'High Clarity',
236     'high-strength': 'High Strength'
237 }
238
239 profile_order = {
240     'medium-quality': 0,
241     'high-speed': 1,
242     'high-quality': 2,
243     'high-clarity': 3,
244     'high-strength': 4
245 }
246
247 disable_materials = {
248     'PET': ('High', 'Low', 'Normal', 'Ulti'),
249     'PLA': ('High', 'Low', 'Normal', 'Ulti'),
250     'ABS': ('High', 'Low', 'Normal', 'Ulti')
251 }
252
253 def find_files_for_material(files, material):
254     result = []
255     for file in files:
256         filename = os.path.basename(file)
257         if filename.startswith(material):
258             for p in profile_map.keys():
259                 if filename.startswith(material + "_" + p):
260                     profile = p
261                     result.append((file, material, profile))
262     return result
263     
264 def create_machine_type(machine_type, path, dir):
265     files = glob.glob(os.path.join(path, "*.ini"))
266     path = os.path.join(CURA_QUICKPRINT_DIR, machine_type)
267     for m in material_map.keys():
268         result = find_files_for_material(files, material_map[m])
269         for (file, material, profile) in result:
270             material = m
271             if file is None or material is None or profile is None:
272                 continue
273             filename = os.path.basename(file)
274             profile_file = os.path.join("..", "..", "..", PROFILES_DIR, dir, filename)
275             if not os.path.exists(os.path.join(path, material, profile)):
276                 os.makedirs(os.path.join(path, material, profile))
277             with open(os.path.join(path, material, 'material.ini'), 'w') as f:
278                 f.write("[info]\n")
279                 f.write("name = %s\n" % material_names[material])
280                 order = material_order[material]
281                 if material_types.has_key(material):
282                     types = material_types[material]
283                     if (material == "HIPS_eSUN" and machine_type.startswith("lulzbot_mini")) or \
284                        (material == "ABS_VP" and machine_type.startswith("lulzbot_TAZ")):
285                         types = types + "|First Run"
286                         order = 0
287                     f.write("material_types = %s\n" % types)
288                 f.write("order = %d\n" % order)
289                 if material_url.has_key(material):
290                     f.write("url = %s\n" % material_url[material])
291             with open(os.path.join(path, material, profile, 'profile.ini'), 'w') as f:
292                 f.write("[info]\n")
293                 f.write("name = %s\n" % profile_map[profile])
294                 f.write("order = %d\n" % profile_order[profile])
295                 f.write("profile_file = %s\n" % profile_file)
296     for material in disable_materials.keys():
297         if os.path.exists(os.path.join(path, material)):
298             for profile in disable_materials[material]:
299                 if not os.path.exists(os.path.join(path, material, profile)):
300                     os.makedirs(os.path.join(path, material, profile))
301                     with open(os.path.join(path, material, profile, 'profile.ini'), 'w') as f:
302                         f.write("[info]\n")
303                         f.write("disabled = true\n")
304         else:
305             os.makedirs(os.path.join(path, material))
306             with open(os.path.join(path, material, 'material.ini'), 'w') as f:
307                 f.write("[info]\n")
308                 f.write("disabled = true\n")
309                 
310
311 def main():
312     if not os.path.exists(CURA_QUICKPRINT_DIR):
313         print "Cura path is wrong"
314         return -1
315
316     dirs = glob.glob(os.path.join(CURA_QUICKPRINT_DIR, PROFILES_DIR, "*"))
317
318     for d in dirs:
319         dir = os.path.basename(d)
320         if dir_map.has_key(dir):
321             for machine_type in dir_map[dir]:
322                 create_machine_type(machine_type, d, dir)
323
324     print "All done :D"
325
326
327 if __name__ == '__main__':
328     main()