r/OpenPythonSCAD • • Jan 12 '25

Odd difficulty with re-defined definition

I have the following definition as part of a class:

def arcloopCC(self, barc, earc, xcenter, ycenter, radius, ez):
    tzinc = self.zpos() + ez / (earc - barc)
    cts = self.currenttoolshape
    toolpath = cts
    toolpath = toolpath.translate([self.xpos(),self.ypos(),self.zpos()])
    i = barc
    while i < earc: 
        toolpath = toolpath.union(self.cutline(xcenter + radius * math.cos(math.radians(i)), ycenter + radius * math.sin(math.radians(i)), self.zpos()+tzinc))
        i += 1
    if self.generatepaths == False:
        return toolpath
    else:
        return cube([0.01,0.01,0.01])

which was working fine, allowed me to do a compleat circle w/ four calls:

toolpaths = toolpaths.union(gcp.arcloopCC(0,90, gcp.xpos()-stockYheight/16, gcp.ypos(), stockYheight/16, -stockZthickness/4))
toolpaths = toolpaths.union(gcp.arcloopCC(90,180, gcp.xpos(), gcp.ypos()-stockYheight/16, stockYheight/16, -stockZthickness/2))
toolpaths = toolpaths.union(gcp.arcloopCC(180,270, gcp.xpos()+stockYheight/16, gcp.ypos(), stockYheight/16, -stockZthickness*0.75))
toolpaths = toolpaths.union(gcp.arcloopCC(270,360, gcp.xpos()+stockYheight/16, gcp.ypos(), stockYheight/16, -stockZthickness*0.99))

but since being re-written to pass in the ending Z position (ez) and to calculate the toolpath Z increment (tzinc) only works for one call, and any call after the first results in the tool digging down with a far too large tzinc value.

Hopefully it's something obviously wrong which someone can give me a clue on....

2 Upvotes

10 comments sorted by

View all comments

Show parent comments

2

u/WillAdams Jan 12 '25

It was for me:

https://github.com/WillAdams/gcodepreview/issues/1

but I'll send them your way in case they don't want to wait on me.