Skip to content

Commit

Permalink
Polardetect (#1)
Browse files Browse the repository at this point in the history
* polar mapping when diameter less than maxx

* fix naming

* only calc max arc if not in polar

* give wrapdiam some non-zero value

* fix mapping name

* version bump
  • Loading branch information
paukstelis authored Jul 30, 2024
1 parent 8100858 commit fcc8854
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions octoprint_gcode_ripper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def generate_gcode(self):
gcr = G_Code_Rip.G_Code_Rip()
gcode_file = self.selected_file
gcr.Read_G_Code("{}/{}".format(self._settings.getBaseFolder("uploads"), gcode_file), XYarc2line=True, units="mm")
self.mapping = "Y2A"
polar = False
wrapdiam = self.start_diameter + 2*(self.currentZ)
output_name = "D{0}_R{1}_".format(int(wrapdiam), int(self.rotation))
output_path = output_name+self.template_name
Expand All @@ -72,19 +74,28 @@ def generate_gcode(self):
midy = (miny+maxy)/2
x_zero = midx
y_zero = midy
#Refactor for polar coordinate case
if self.start_diameter < maxx:
output_name = "POLAR_R{0}_".format(int(self.rotation))
output_path = output_name+self.template_name
path_on_disk = "{}/{}".format(self._settings.getBaseFolder("watched"), output_path)
self.mapping = "Polar"
polar = True
wrapdiam=0.5

temp = gcr.scale_translate(temp,translate=[x_zero,y_zero,0.0])
gcr.scaled_trans = temp
minx = minx - x_zero
maxx = maxx - x_zero
miny = miny - y_zero
maxy = maxy - y_zero
mina = math.degrees(miny/(wrapdiam/2))
maxa = math.degrees(maxy/(wrapdiam/2))
maxarc = (abs(mina) + abs(maxa))
if not polar:
mina = math.degrees(miny/(wrapdiam/2))
maxa = math.degrees(maxy/(wrapdiam/2))
maxarc = (abs(mina) + abs(maxa))
pre = "DOBANGLE\nDIAM {0}\n".format(wrapdiam)

if self.modifyA:
if self.modifyA and not polar:
pre = pre + "DOMODA\nMAXARC {0:.3f}".format(maxarc)

with open(path_on_disk,"w") as newfile:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-Gcode_ripper"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.1.2"
plugin_version = "0.1.3"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit fcc8854

Please sign in to comment.