add estimation

This commit is contained in:
Mario Voigt 2021-11-02 20:34:09 +01:00
parent f98e9719ab
commit 2ea449bfb6
2 changed files with 35 additions and 10 deletions

View File

@ -3,8 +3,20 @@
<name>Laser Check</name>
<id>fablabchemnitz.de.laser_check</id>
<param name="tab" type="notebook">
<page name="tab_settings" gui-text="Checks">
<page name="tab_settings" gui-text="Laser Check">
<label appearance="header">General</label>
<param name="show_issues_only" type="bool" gui-text="Show potential issues only" gui-description="Shortens the report a little bit">false</param>
<separator/>
<label appearance="header">Machine Settings</label>
<param name="machine_size" gui-text="Machine/Size (mm)" type="optiongroup" appearance="combo">
<option value="406x305">406 x 305 mm (Zing 16)</option>
<option value="610x305">610 x 305 mm (Zing 24 / Fusion Edge 12)</option>
<option value="812x508">812 x 508 mm (Fusion Pro 32 / Fusion M2 32)</option>
<option value="1016x711">1016 x 711 mm (Fusion M2 40)</option>
<option value="1219x914">1219 x 914 mm (Fusion Pro 48)</option>
</param>
<param name="max_cutting_speed" type="float" min="0.000" max="9999.000" gui-text="Max. cutting speed (mm/s)">100</param>
<label appearance="header">Checks</label>
<param name="checks" type="optiongroup" appearance="combo" gui-text="Select checks">
<option value="check_all">Check all</option>
<option value="check_section">Check selection</option>
@ -15,14 +27,8 @@
<vbox>
<param name="bbox" type="bool" gui-text="Bounding box">false</param>
<param name="bbox_offset" type="float" min="0.000" max="9999.000" precision="3" gui-text="Minimum required offset (mm)">5.000</param>
<param name="machine_size" gui-text="Machine/Size (mm)" type="optiongroup" appearance="combo">
<option value="406x305">406 x 305 mm (Zing 16)</option>
<option value="610x305">610 x 305 mm (Zing 24 / Fusion Edge 12)</option>
<option value="812x508">812 x 508 mm (Fusion Pro 32 / Fusion M2 32)</option>
<option value="1016x711">1016 x 711 mm (Fusion M2 40)</option>
<option value="1219x914">1219 x 914 mm (Fusion Pro 48)</option>
</param>
<separator/>
<param name="cutting_estimation" type="bool" gui-text="Cutting time estimation">false</param>
<param name="elements_outside_canvas" type="bool" gui-text="Elements outside canvas">false</param>
<param name="groups_and_layers" type="bool" gui-text="Groups and layers">false</param>
<param name="clones" type="bool" gui-text="Clones">false</param>

View File

@ -17,10 +17,12 @@ class LaserCheck(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument('--tab')
pars.add_argument('--show_issues_only', type=inkex.Boolean, default=False)
pars.add_argument('--checks', default="check_all")
pars.add_argument('--show_issues_only', type=inkex.Boolean, default=False)
pars.add_argument('--max_cutting_speed', type=float, default=100)
pars.add_argument('--bbox', type=inkex.Boolean, default=False)
pars.add_argument('--bbox_offset', type=float, default=5.000)
pars.add_argument('--cutting_estimation', type=inkex.Boolean, default=False)
pars.add_argument('--machine_size', default="812x508")
pars.add_argument('--elements_outside_canvas', type=inkex.Boolean, default=False)
pars.add_argument('--groups_and_layers', type=inkex.Boolean, default=False)
@ -517,7 +519,24 @@ class LaserCheck(inkex.EffectExtension):
for shortPath in shortPaths:
inkex.utils.debug("id={}, length={}mm".format(shortPath[0].get('id'), round(self.svg.uutounit(str(shortPath[1]), "mm"), 3)))
'''
Really short paths can cause issues with laser cutter mechanics and should be avoided to
have healthier stepper motor belts, etc.
'''
if so.checks == "check_all" or so.cutting_estimation is True:
inkex.utils.debug("\n---------- Cutting time estimation")
totalLength = 0
for element in shapes:
if isinstance(element, inkex.PathElement):
slengths, stotal = csplength(element.path.transform(element.composed_transform()).to_superpath())
totalLength += stotal
inkex.utils.debug("cutting length (mm) = {:0.2f} mm".format(self.svg.uutounit(str(totalLength), "mm"), self.svg.uutounit(str(totalLength), "mm")))
for f in range(100, 0, -10):
v = so.max_cutting_speed * f/100.0
tsec = totalLength / v
tmin = tsec / 60
inkex.utils.debug("cutting time @{:0.0f}% (={}mm/s): {:0.2f}min (={:0.1f}s)".format(f, v, tmin, tsec))
'''
Paths with a high amount of nodes will cause issues because each node means slowing down/speeding up the laser mechanics