Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Simplify3d profile inference support #197

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion continuousprint/data/printer_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ PrinterProfile:
clearBed: Pause
finished: Generic Off
depth: 210
extra_tags: []
extra_tags: ["MK3", "MK3S"]
formFactor: rectangular
height: 210
make: Prusa
Expand Down
20 changes: 19 additions & 1 deletion continuousprint/scripts/extract_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ def get_profile(self, hdr, ftr) -> str:
return ""


class Simplify3DProcessor:
@classmethod
def match(self, hdr, ftr):
for line in hdr:
if line.startswith("; G-Code generated by Simplify3D"):
return True
return False

@classmethod
def get_profile(self, hdr, ftr) -> str:
for line in hdr:
m = re.match("; profileName,(.*)", line)
print(line, "->", m)
if m is not None:
return m[1]
return ""


def token_string_match(profstr):
# Remove non-alpha characters from profile string
# Convert all into bag-of-words
Expand All @@ -72,7 +90,7 @@ def token_string_match(profstr):

PROCESSORS = [
(cls.__name__, cls.match, cls.get_profile)
for cls in [KiriMotoProcessor, PrusaSlicerProcessor]
for cls in [KiriMotoProcessor, PrusaSlicerProcessor, Simplify3DProcessor]
]

gcode_move_re = re.compile("^G[012] .*")
Expand Down
5 changes: 5 additions & 0 deletions continuousprint/scripts/test_extract_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def testParameterized(self):
"; printer_model = MK3S\n",
"Prusa i3 MK3S+",
),
(
"; G-Code generated by Simplify3D(R) Version 4.1.2\n; profileName,Prusa Research Original Prusa i3 MK3",
"",
"Prusa i3 MK3S+",
),
]:
with self.subTest(header=header, footer=footer, want=want):
hdr = header.split("\n")
Expand Down