Example #1
0
    def __str__(self):
        '''Get the string representation.'''
        output = StringIO()

        output.write("\nRuntimeParameters:\n%s\n" % vars(self.runtimeParameters))

        output.write("\nelementOffsets: %s\n" % self.elementOffsets)

        output.write("\nrotatedLoopLayers:\n")
        for rotatedLoopLayer in self.rotatedLoopLayers:
            output.write('%s\n' % vars(rotatedLoopLayer))

        output.write("\nstartGcodeCommands:\n")
        for startGcodeCommand in self.startGcodeCommands:
            output.write(GcodeCommand.printCommand(startGcodeCommand, self.runtimeParameters.verboseGcode))

        output.write("\nlayers:\n")
        for layer in self.layers:
            output.write('%s\n' % layer)

        output.write("\nendGcodeCommands:\n")
        for endGcodeCommand in self.endGcodeCommands:
            output.write(GcodeCommand.printCommand(endGcodeCommand, self.runtimeParameters.verboseGcode))

        return output.getvalue()
Example #2
0
    def getRetractReverseCommands(self):

        commands = []

        if self.extrusionUnitsRelative:
            retractDistance = round(self.lastRetractDistance,
                                    self.dimensionDecimalPlaces)
        else:
            self.extrusionDistance += self.lastRetractDistance
            retractDistance = round(self.extrusionDistance,
                                    self.dimensionDecimalPlaces)

        commands.append(
            GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT,
                         [('F', '%s' % self.extruderRetractionSpeedMinute)]))
        commands.append(
            GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT,
                         [('%s' % self.axisCode, '%s' % retractDistance)]))
        commands.append(
            GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT,
                         [('F', '%s' % self.travelFeedRateMinute)]))

        if not self.extrusionUnitsRelative:
            commands.append(self.getResetExtruderDistanceCommand())

        return commands
Example #3
0
    def getRetractCommands(self, idleTime, resumingSpeed):

        commands = []

        retractDistance = min(idleTime * abs(self.oozeRate) / 60,
                              self.maximumRetractionDistance)
        self.lastRetractDistance = retractDistance

        if self.extrusionUnitsRelative:
            retractDistance = round(-retractDistance,
                                    self.dimensionDecimalPlaces)
        else:
            self.extrusionDistance -= retractDistance
            retractDistance = round(self.extrusionDistance,
                                    self.dimensionDecimalPlaces)

        commands.append(
            GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT,
                         [('F', '%s' % self.extruderRetractionSpeedMinute)]))
        commands.append(
            GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT,
                         [('%s' % self.axisCode, '%s' % retractDistance)]))
        commands.append(
            GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT,
                         [('F', '%s' % resumingSpeed)]))

        return commands
Example #4
0
    def __str__(self):
        '''Get the string representation.'''
        output = StringIO()

        output.write("\nRuntimeParameters:\n%s\n" %
                     vars(self.runtimeParameters))

        output.write("\nelementOffsets: %s\n" % self.elementOffsets)

        output.write("\nrotatedLoopLayers:\n")
        for rotatedLoopLayer in self.rotatedLoopLayers:
            output.write('%s\n' % vars(rotatedLoopLayer))

        output.write("\nstartGcodeCommands:\n")
        for startGcodeCommand in self.startGcodeCommands:
            output.write(
                GcodeCommand.printCommand(startGcodeCommand,
                                          self.runtimeParameters.verboseGcode))

        output.write("\nlayers:\n")
        for layer in self.layers:
            output.write('%s\n' % layer)

        output.write("\nendGcodeCommands:\n")
        for endGcodeCommand in self.endGcodeCommands:
            output.write(
                GcodeCommand.printCommand(endGcodeCommand,
                                          self.runtimeParameters.verboseGcode))

        return output.getvalue()
Example #5
0
    def moveToStartPoint(self, height, feedAndFlowRateMultiplier):
        '''Adds gcode to move the nozzle to the startpoint of the path.
            If comb is active the path will dodge all open spaces.
        '''
        startPointPath = []
        global _previousPoint

        if self.combActive and self.fromLocation != None and self.combSkein != None:

            additionalCommands = self.combSkein.getPathsBetween(
                self.z + height, self.fromLocation.dropAxis(),
                self.toLocation.dropAxis())
            startPointPath.extend(additionalCommands)

        startPointPath.append(self.toLocation.dropAxis())

        for point in startPointPath:
            gcodeArgs = [('X', round(point.real, self.decimalPlaces)),
                         ('Y', round(point.imag, self.decimalPlaces)),
                         ('Z', round(self.z + height, self.decimalPlaces))]

            if self.speedActive:
                travelFeedRateMinute, travelFeedRateMultiplier = self.getFeedRateAndMultiplier(
                    self.travelFeedRateMinute, feedAndFlowRateMultiplier)
                gcodeArgs.append(
                    ('F',
                     self.travelFeedRateMinute * travelFeedRateMultiplier))

            if self.absolutePositioning:
                _previousPoint = point
            else:
                _previousPoint += point

            self.gcodeCommands.append(
                GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT, gcodeArgs))
Example #6
0
 def __str__(self):
     '''Get the string representation.'''
     output = StringIO()
     output.write('%14stype: %s\n' % ('', self.type))
     output.write('%14sstartPoint: %s\n' % ('', self.startPoint))
     output.write('%14spoints: %s\n' % ('', self.points))
     output.write('%14sgcodeCommands:\n' % '')
     for command in self.gcodeCommands:
         output.write('%16s%s' % ('', GcodeCommand.printCommand(command)))
     return output.getvalue()
Example #7
0
 def __str__(self):
     '''Get the string representation.'''
     output = StringIO()
     output.write('%14stype: %s\n' % ('', self.type))
     output.write('%14sstartPoint: %s\n' % ('', self.startPoint))
     output.write('%14spoints: %s\n' % ('', self.points))
     output.write('%14sgcodeCommands:\n' % '')
     for command in self.gcodeCommands:
         output.write('%16s%s' % ('', GcodeCommand.printCommand(command)))
     return output.getvalue()    
Example #8
0
    def generateGcode(self,
                      pathExtruder,
                      height,
                      lookaheadStartVector=None,
                      feedAndFlowRateMultiplier=[1.0, 1.0],
                      runtimeParameters=None):
        'Transforms paths and points to gcode'
        global _previousPoint

        if runtimeParameters != None:
            self._setParameters(runtimeParameters)

        if _previousPoint == None:
            _previousPoint = self.startPoint

        if self.dimensionActive:

            if self.fromLocation != None:

                locationMinusOld = self.toLocation - self.fromLocation
                xyTravel = abs(locationMinusOld.dropAxis())
                zTravelMultiplied = locationMinusOld.z * self.zDistanceRatio
                timeToNextThread = math.sqrt(
                    xyTravel * xyTravel + zTravelMultiplied *
                    zTravelMultiplied) / self.extrusionFeedRateMinute * 60
            else:
                timeToNextThread = 0.0

            self.gcodeCommands.extend(
                pathExtruder.getRetractCommands(timeToNextThread,
                                                self.getFeedRateMinute()))

        self.gcodeCommands.append(GcodeCommand(gcodes.TURN_EXTRUDER_OFF))

        self.moveToStartPoint(height, feedAndFlowRateMultiplier[0])

        if self.dimensionActive:
            #_previousPoint = self.startPoint
            self.gcodeCommands.extend(pathExtruder.getRetractReverseCommands())

        self.gcodeCommands.append(GcodeCommand(gcodes.TURN_EXTRUDER_ON))
Example #9
0
    def generateGcode(self,
                      extruder,
                      height,
                      lookaheadStartVector=None,
                      feedAndFlowRateMultiplier=[1.0, 1.0],
                      runtimeParameters=None):
        'Transforms paths and points to gcode'
        global _previousPoint
        self.gcodeCommands = []

        if runtimeParameters != None:
            self._setParameters(runtimeParameters)

        if _previousPoint == None:
            _previousPoint = self.startPoint

        for point in self.points:

            gcodeArgs = [('X', round(point.real, self.decimalPlaces)),
                         ('Y', round(point.imag, self.decimalPlaces)),
                         ('Z', round(self.z + height, self.decimalPlaces))]

            pathFeedRateMinute = self.getFeedRateMinute()
            flowRate = self.getFlowRate()

            (pathFeedRateMinute,
             pathFeedRateMultiplier) = self.getFeedRateAndMultiplier(
                 pathFeedRateMinute, feedAndFlowRateMultiplier[0])

            if self.speedActive:
                gcodeArgs.append(('F', pathFeedRateMinute))

            if self.dimensionActive:
                if self.absolutePositioning:
                    distance = abs(point - _previousPoint)
                    _previousPoint = point

                extrusionDistance = extruder.getExtrusionDistance(
                    distance, flowRate * feedAndFlowRateMultiplier[1],
                    pathFeedRateMinute)
                gcodeArgs.append(
                    ('%s' % extruder.axisCode, '%s' % extrusionDistance))

            self.gcodeCommands.append(
                GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT, gcodeArgs))
Example #10
0
    def getResetExtruderDistanceCommand(self):

        self.extrusionDistance = 0.0
        return GcodeCommand(gcodes.RESET_EXTRUDER_DISTANCE, [('E', '0')])