1
1
"""State generator module."""
2
2
3
+ import math
3
4
import pathlib
4
5
import re
5
6
from typing import List , Match
81
82
default_virtual_machine = {
82
83
"absolute_position" : True ,
83
84
"absolute_extrusion" : True ,
85
+ "volumetric_extrusion" : False ,
84
86
"units" : "SI (mm)" ,
85
87
"initial_position" : None ,
86
88
# general properties
@@ -207,6 +209,24 @@ def dict_list_traveler(line_dict_list: List[dict], initial_machine_setup: dict)
207
209
state_list: (list[state]) all states in a list
208
210
209
211
"""
212
+
213
+ def apply_extrusion (line_dict : dict , virtual_machine : dict , command : str ) -> dict :
214
+ e_value = line_dict [command ]["E" ]
215
+
216
+ # volumetric to length conversion
217
+ # (1) V = (d/2)^2 * pi * E
218
+ # (2) E = V / ((d/2)^2 * pi)
219
+ if virtual_machine .get ("volumetric_extrusion" , False ):
220
+ # volumetric extrusion
221
+ e_value = e_value / (math .pi * (virtual_machine ["filament_diam" ] / 2 ) ** 2 )
222
+
223
+ if virtual_machine ["absolute_extrusion" ]:
224
+ virtual_machine ["E" ] = e_value
225
+ else :
226
+ virtual_machine ["E" ] = virtual_machine ["E" ] + e_value
227
+
228
+ return virtual_machine
229
+
210
230
state_list : List [state ] = list ()
211
231
212
232
virtual_machine = {
@@ -225,17 +245,15 @@ def dict_list_traveler(line_dict_list: List[dict], initial_machine_setup: dict)
225
245
layer_counter = 0
226
246
227
247
# overwrite default values from initial machine setup
228
- """TODO: depending on the setting the user should be informed that a default value is used.
229
- I prepared a warning below.
230
- Are all these settings necessary?"""
231
248
for key in default_virtual_machine :
232
249
if initial_machine_setup is not None and key in initial_machine_setup :
233
250
virtual_machine [key ] = initial_machine_setup [key ]
234
251
else :
235
- """print (
252
+ custom_print (
236
253
f"The parameter '{ key } ' was not specified in your machine presets. "
237
- f"Using the the default value of '{default_virtual_machine[key]}' to continue."
238
- )"""
254
+ f"Using the the default value of '{ default_virtual_machine [key ]} ' to continue." ,
255
+ lvl = 3 ,
256
+ )
239
257
virtual_machine [key ] = default_virtual_machine [key ]
240
258
241
259
# initial state creation
@@ -298,10 +316,9 @@ def dict_list_traveler(line_dict_list: List[dict], initial_machine_setup: dict)
298
316
299
317
# look for extrusion commands and apply abs/rel
300
318
if "E" in line_dict [command ]:
301
- if virtual_machine ["absolute_extrusion" ] is True :
302
- virtual_machine ["E" ] = line_dict [command ]["E" ]
303
- if virtual_machine ["absolute_extrusion" ] is False : # redundant
304
- virtual_machine ["E" ] = virtual_machine ["E" ] + line_dict [command ]["E" ]
319
+ virtual_machine = apply_extrusion (line_dict , virtual_machine , command )
320
+
321
+ # feed rates in unit/min to unit/sec
305
322
if "F" in line_dict [command ]:
306
323
virtual_machine ["p_vel" ] = line_dict [command ]["F" ] / 60
307
324
0 commit comments