示例#1
0
 def __str__(self):
     if self.ccw:
         s = "CCW ArcTo: "
     else:
         s = "CW ArcTo: "
     return s + str(Wrappers.Point(self.toPoint)) + ", center=" + str(
         Wrappers.Point(self.centerPoint))
示例#2
0
    def gcode(self, shapeList):
        "convert the list of shapes to gcode"
        "returns a generator of gcode lines"
        "listOfShape is a list of wires, edges, or compounds of these"

        pe = PathExport.ShapeDraw(self.options.useArcs,
                                  self.options.curveApproximationTolerance)

        for move in pe.follow(shapeList):
            log.debug(move)
            cmd = []
            moveType = move.__class__.__name__

            #regardless of whether we're doing an arc or linear move,
            #we'll need to know the end X, Y, and Z values
            if self.incremental:
                compareVals = [0, 0, 0]
                moveVals = move.distance()
            else:
                compareVals = [
                    self.currentPosition.X(),
                    self.currentPosition.Y(),
                    self.currentPosition.Z()
                ]
                moveVals = move.vector()
            log.debug("CompareVals" + str(compareVals))
            log.debug("MoveVals" + str(moveVals))
            c = self._appendAxisValues(compareVals, moveVals)
            log.debug("Computed Move" + str(c))
            if moveType == "LinearMove":
                if len(c) > 0:
                    if move.draw:
                        cmd.append("G01")
                    else:
                        cmd.append("G00")
                    cmd.extend(c)

            elif moveType == "ArcMove":
                "it is an arc move"
                if move.ccw:
                    cmd.append("G03")
                else:
                    cmd.append("G02")
                #I and J are always relative to the start point. of the arc. but
                #X, Y, and Z have to honor incremental or absolute mode
                i = move.centerPoint.X() - move.fromPoint.X()
                j = move.centerPoint.Y() - move.fromPoint.Y()
                cmd.append("I" + self.options.numberFormat % i)
                cmd.append("J" + self.options.numberFormat % j)
                cmd.extend(c)

            else:
                cmd.append("Unknown Move Type" + moveType)

            if self.options.computeExtraAxis and len(cmd) > 0:
                cmd.append(self.options.extraAxisName +
                           (self.options.numberFormat % move.length()))

            if len(cmd) > 0:
                yield " ".join(cmd) + "\n"

            self.lastMove = move
            self.currentPosition = move.toPoint
            log.debug("CurrentPosition = " +
                      str(Wrappers.Point(self.currentPosition)))
示例#3
0
 def __str__(self):
     if self.draw:
         s = "DrawTo: "
     else:
         s = "MoveTo: "
     return s + str(Wrappers.Point(self.toPoint))