Skip to content

Commit

Permalink
Update RetractTower.py
Browse files Browse the repository at this point in the history
  • Loading branch information
5axes committed Jun 2, 2021
1 parent 6213a36 commit edeec83
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions resources/RetractTower.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Version 1.1 29/01/2021
# Version 1.2 19/02/2021 : First instruction output
# Version 1.3 18/04/2021 : ChangeLayerOffset += 2
# Version 1.4 18/04/2021 : Magane G91/G90 in code
#
#------------------------------------------------------------------------------------------------------------------------------------

Expand All @@ -20,7 +21,7 @@
import re #To perform the search
from enum import Enum

__version__ = '1.3'
__version__ = '1.4'

class Section(Enum):
"""Enum for section type."""
Expand Down Expand Up @@ -77,17 +78,27 @@ def is_not_extrusion_line(line: str) -> bool:
"""
return "G0" in line and "X" in line and "Y" in line and not "E" in line

def is_begin_skin_segment_line(line: str) -> bool:
"""Check if current line is the start of an skin.
def is_relative_instruction_line(line: str) -> bool:
"""Check if current line contain a M83 / G91 instruction
Args:
line (str): Gcode line
Returns:
bool: True if the line is the start of an skin section
bool: True contain a M83 / G91 instruction
"""
return line.startswith(";TYPE:SKIN")

return "G91" in line or "M83" in line

def is_not_relative_instruction_line(line: str) -> bool:
"""Check if current line contain a M82 / G91 instruction
Args:
line (str): Gcode line
Returns:
bool: True contain a M82 / G91 instruction
"""
return "G90" in line or "M82" in line

class RetractTower(Script):
def __init__(self):
Expand All @@ -103,7 +114,7 @@ def getSettingDataString(self):
{
"command": {
"label": "Command",
"description": "GCode Commande",
"description": "G-Code Commande",
"type": "enum",
"options": {
"speed": "Speed",
Expand Down Expand Up @@ -197,6 +208,11 @@ def execute(self, data):
for line in lines:
line_index = lines.index(line)

if is_relative_instruction_line(line):
relative_extrusion = True
if is_not_relative_instruction_line(line):
relative_extrusion = False

# If we have define a value
if CurrentValue>=0:
if is_retract_line(line):
Expand Down

0 comments on commit edeec83

Please sign in to comment.