Exemplo n.º 1
0
	def getCraftedGcode( self, gcodeText, homeRepository ):
		"Parse gcode text and store the home gcode."
		self.homingText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname(__file__), homeRepository.nameOfHomingFile.value )
		if len( self.homingText ) < 1:
			return gcodeText
		self.lines = archive.getTextLines(gcodeText)
		self.homeRepository = homeRepository
		self.parseInitialization( homeRepository )
		self.homingLines = archive.getTextLines( self.homingText )
		for self.lineIndex in xrange( self.lineIndex, len(self.lines) ):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 2
0
def getReplaced(exportText):
	'Get text with strings replaced according to replace.csv file.'
	replaceText = settings.getFileInAlterationsOrGivenDirectory(os.path.dirname(__file__), 'Replace.csv')
	replaceLines = archive.getTextLines(replaceText)
	if len(replaceLines) < 1:
		return exportText
	for replaceLine in replaceLines:
		splitLine = replaceLine.replace('\\n', '\t').split('\t')
		if len(splitLine) > 0:
			exportText = exportText.replace(splitLine[0], '\n'.join(splitLine[1 :]))
	output = cStringIO.StringIO()
	gcodec.addLinesToCString(output, archive.getTextLines(exportText))
	return output.getvalue()
Exemplo n.º 3
0
	def __init__(self, slicedModel):
		self.slicedModel = slicedModel
		
		self.turnFanOnAtBeginning = config.getboolean(name, 'turn.on.fan.at.beginning')
		self.turnFanOffAtEnding = config.getboolean(name, 'turn.off.fan.at.end')
		self.nameOfCoolStartFile = config.get(name, 'cool.start.file')
		self.nameOfCoolEndFile = config.get(name, 'cool.end.file')
		self.coolStrategyName = config.get(name, 'strategy')
		self.coolStrategyPath = config.get(name, 'strategy.path')
		self.absoluteCoolStartFilePath = os.path.join('alterations', self.nameOfCoolStartFile)
		self.absoluteCoolEndFilePath = os.path.join('alterations', self.nameOfCoolEndFile)
		self.coolStartLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
		self.coolEndLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
Exemplo n.º 4
0
	def getCraftedGcode(self, gcodeText, repository):
		'Parse gcode text and store the dimension gcode.'
		self.repository = repository
		filamentRadius = 0.5 * repository.filamentDiameter.value
		xSectionCorrector = repository.MeasuredXSection.value
		filamentPackingArea = math.pi * filamentRadius * filamentRadius * repository.filamentPackingDensity.value
		#self.minimumExtrusionForRetraction = 0 #self.repository.minimumExtrusionForRetraction.value
		#self.minimumTravelForRetraction = 0 # self.repository.minimumTravelForRetraction.value
		self.doubleMinimumTravelForRetraction = 0#self.minimumTravelForRetraction + self.minimumTravelForRetraction
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		#if self.repository.retractWhenCrossing.value:
		self.parseBoundaries()
		self.calibrationFactor = 1
		if repository.activateCalibration.value:
			self.calibrationFactor = (((self.layerThickness**2/4)*math.pi)+self.layerThickness*(xSectionCorrector -self.layerThickness))/(((self.layerThickness**2/4)*math.pi)+self.layerThickness *(self.perimeterWidth-self.layerThickness))
		self.newfilamentPackingDensity = repository.filamentPackingDensity.value * self.calibrationFactor
		print('****************Filament Packing Density (For Calibration)**********************:')
		print( 'Filament Packing Density (For Calibration) STEPPER EXTRUDERS ONLY :', self.newfilamentPackingDensity )
		print('****************Filament Packing Density (For Calibration)**********************')
		self.flowScaleSixty = 60.0 * ((((self.layerThickness+self.perimeterWidth)/4) ** 2 * math.pi )/filamentPackingArea) / self.calibrationFactor
		#print ('filamentPackingArea self.calibrationFactor',filamentPackingArea ,self.calibrationFactor)
		if self.calibrationFactor is None:
			print('Measured extrusion width cant be 0, either un-check calibration or set measured width to what you have measured!')
		if self.operatingFlowRate == None:
			print('There is no operatingFlowRate so dimension will do nothing.')
			return gcodeText
#		self.restartDistance = self.autoRetractDistance #self.repository.retractionDistance.value# + (self.repository.restartExtraDistance.value) *self.autoRetractDistance
#		((self.restartDistance * self.retractionRatio) - (self.restartDistance * self.retractionRatio)* self.autoRetractDistance)
		self.extruderRetractionSpeedMinuteString = self.distanceFeedRate.getRounded(60.0 * self.repository.extruderRetractionSpeed.value)
		if self.maximumZTravelFeedRatePerSecond != None and self.travelFeedRatePerSecond != None:
			self.zDistanceRatio = self.travelFeedRatePerSecond / self.maximumZTravelFeedRatePerSecond
		for lineIndex in xrange(self.lineIndex, len(self.lines)):
			self.parseLine( lineIndex )
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 5
0
	def getCraftedGcode(self, gcodeText, repository):
		"""Parse gcode text and store the dimension gcode."""
		self.repository = repository
		filamentRadius = 0.5 * repository.filamentDiameter.value
		xSectionCorrector = repository.MeasuredXSection.value
		filamentPackingArea = math.pi * filamentRadius * filamentRadius * repository.filamentPackingDensity.value
		self.minimumExtrusionForRetraction = self.repository.minimumExtrusionForRetraction.value
		self.minimumTravelForRetraction = self.repository.minimumTravelForRetraction.value
		self.doubleMinimumTravelForRetraction = self.minimumTravelForRetraction + self.minimumTravelForRetraction
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		if self.repository.retractWhenCrossing.value:
			self.parseBoundaries()
		self.calibrationFactor = 1
		if repository.activateCalibration.value:
			self.calibrationFactor = (((self.extrusionHeight/2)*(self.extrusionHeight/2)*math.pi)+self.extrusionHeight*(xSectionCorrector -self.extrusionHeight))/(((self.extrusionHeight/2)*(self.extrusionHeight/2)*math.pi)+self.extrusionHeight *(self.extrusionWidth-self.extrusionHeight))
		self.newfilamentPackingDensity = repository.filamentPackingDensity.value * self.calibrationFactor
		print('****************Filament Packing Density (For Calibration)**********************:')
		print( self.newfilamentPackingDensity )
		self.flowScaleSixty = 60.0 * ((((self.extrusionHeight+self.extrusionWidth)/4) ** 2 * math.pi )/filamentPackingArea) / self.calibrationFactor
		if self.calibrationFactor is None:
			print('Mesaured extrusion width cant be 0, either un-check calibration or set mewsured width to what you have measured!')			
		if self.operatingFlowRate is None:
			print('There is no operatingFlowRate so dimension will do nothing.')
			return gcodeText
		self.restartDistance = self.repository.retractionDistance.value + self.repository.restartExtraDistance.value
		self.extruderRetractionSpeedMinuteString = self.distanceFeedRate.getRounded(60.0 * self.repository.extruderRetractionSpeed.value)
		if self.maximumZTravelFeedRate is not None and self.travelFeedRate is not None:
			self.zDistanceRatio = self.travelFeedRate / self.maximumZTravelFeedRate
		for lineIndex in xrange(self.lineIndex, len(self.lines)):
			self.parseLine( lineIndex )
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 6
0
	def parseGcode( self, fileName, gcodeText, repository ):
		"Parse gcode text and store the vector output."
		self.repository = repository
		self.fileName = fileName
		self.gcodeText = gcodeText
		self.initializeActiveLocation()
		self.cornerHigh = Vector3(-999999999.0, -999999999.0, -999999999.0)
		self.cornerLow = Vector3(999999999.0, 999999999.0, 999999999.0)
		self.goAroundExtruderOffTravel = repository.goAroundExtruderOffTravel.value
		self.lines = archive.getTextLines(gcodeText)
		self.isThereALayerStartWord = gcodec.isThereAFirstWord('(<layer>', self.lines, 1 )
		self.parseInitialization()
		for line in self.lines[self.lineIndex :]:
			self.parseCorner(line)
		if len( self.layerTops ) > 0:
			self.layerTops[-1] += 912345678.9
		if len( self.layerTops ) > 1:
			self.oneMinusBrightnessOverTopLayerIndex = ( 1.0 - repository.bottomLayerBrightness.value ) / float( len( self.layerTops ) - 1 )
		self.firstTopLayer = len( self.layerTops ) - self.repository.numberOfFillTopLayers.value
		self.centerComplex = 0.5 * ( self.cornerHigh.dropAxis(2) + self.cornerLow.dropAxis(2) )
		self.centerBottom = Vector3( self.centerComplex.real, self.centerComplex.imag, self.cornerLow.z )
		self.scale = repository.scale.value
		self.scaleCenterBottom = self.scale * self.centerBottom
		self.scaleCornerHigh = self.scale * self.cornerHigh.dropAxis(2)
		self.scaleCornerLow = self.scale * self.cornerLow.dropAxis(2)
		print( "The lower left corner of the skeiniso window is at %s, %s" % ( self.cornerLow.x, self.cornerLow.y ) )
		print( "The upper right corner of the skeiniso window is at %s, %s" % ( self.cornerHigh.x, self.cornerHigh.y ) )
		self.cornerImaginaryTotal = self.cornerHigh.y + self.cornerLow.y
		margin = complex( 5.0, 5.0 )
		self.marginCornerLow = self.scaleCornerLow - margin
		self.screenSize = margin + 2.0 * ( self.scaleCornerHigh - self.marginCornerLow )
		self.initializeActiveLocation()
		for self.lineIndex in xrange( self.lineIndex, len(self.lines) ):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
Exemplo n.º 7
0
def getReplaced(exportText):
	'Get text with strings replaced according to replace.csv file.'
	replaceText = settings.getFileInAlterationsOrGivenDirectory(os.path.dirname(__file__), 'Replace.csv')
	lines = archive.getTextLines(replaceText)
	for line in lines:
		exportText = getReplacedByLine(exportText, line)
	return exportText
Exemplo n.º 8
0
	def getCraftedGcode( self, gcodeText, photographRepository ):
		"Parse gcode text and store the photograph gcode."
		self.photographRepository = photographRepository
		self.lines = archive.getTextLines(gcodeText)
		for line in self.lines[self.lineIndex :]:
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 9
0
	def getCraftedGcode(self, gcodeText, repository):
		"Parse gcode text and store the temperature gcode."
		self.repository = repository
		self.lines = archive.getTextLines(gcodeText)
		if self.repository.coolingRate.value < 0.1:
			print('The cooling rate should be more than 0.1, any cooling rate less than 0.1 will be treated as 0.1.')
			self.repository.coolingRate.value = 0.1
		if self.repository.heatingRate.value < 0.1:
			print('The heating rate should be more than 0.1, any heating rate less than 0.1 will be treated as 0.1.')
			self.repository.heatingRate.value = 0.1
		self.parseInitialization()
		self.baseTemperature = repository.baseTemperature.value
		self.interfaceTemperature = repository.interfaceTemperature.value
		self.objectFirstLayerInfillTemperature = repository.objectFirstLayerInfillTemperature.value
		self.objectFirstLayerPerimeterTemperature = repository.objectFirstLayerPerimeterTemperature.value
		self.objectNextLayersTemperature = repository.objectNextLayersTemperature.value
		self.supportTemperature = repository.supportTemperature.value
		firstTemperature = self.objectFirstLayerInfillTemperature
		if self.threadSequenceFirstString == 'edge':
			firstTemperature = repository.objectFirstLayerPerimeterTemperature.value
		if gcodeText.find('(<baseLayer>)') != -1 and gcodeText.find('(</baseLayer>)') != -1:
			firstTemperature = self.baseTemperature
			self.isRaft = True
		if gcodeText.find('(<interfaceLayer>)') != -1 and gcodeText.find('(</interfaceLayer>)') != -1:
			firstTemperature = self.interfaceTemperature
			self.isRaft = True
		self.addTemperatureLineIfDifferent(firstTemperature)
		for line in self.lines[self.lineIndex :]:
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 10
0
 def parseGcode(self, fileName, gcodeText, repository):
     "Parse gcode text and store the vector output."
     self.fileName = fileName
     self.gcodeText = gcodeText
     self.repository = repository
     self.initializeActiveLocation()
     self.cornerMaximum = Vector3(-999999999.0, -999999999.0, -999999999.0)
     self.cornerMinimum = Vector3(999999999.0, 999999999.0, 999999999.0)
     self.lines = archive.getTextLines(gcodeText)
     self.isThereALayerStartWord = gcodec.isThereAFirstWord("(<layer>", self.lines, 1)
     self.parseInitialization()
     for line in self.lines[self.lineIndex :]:
         self.parseCorner(line)
     self.cornerMaximumComplex = self.cornerMaximum.dropAxis()
     self.cornerMinimumComplex = self.cornerMinimum.dropAxis()
     self.scale = repository.scale.value
     self.scaleCornerHigh = self.scale * self.cornerMaximumComplex
     self.scaleCornerLow = self.scale * self.cornerMinimumComplex
     self.cornerImaginaryTotal = self.cornerMaximum.y + self.cornerMinimum.y
     self.margin = complex(10.0, 10.0)
     self.marginCornerHigh = self.scaleCornerHigh + self.margin
     self.marginCornerLow = self.scaleCornerLow - self.margin
     self.screenSize = self.marginCornerHigh - self.marginCornerLow
     self.initializeActiveLocation()
     self.colorNames = ["brown", "red", "orange", "yellow", "green", "blue", "purple"]
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLine(line)
Exemplo n.º 11
0
	def getCraftedGcode( self, gcodeText, binary16ByteRepository ):
		"Parse gcode text and store the gcode."
		self.binary16ByteRepository = binary16ByteRepository
		lines = archive.getTextLines(gcodeText)
		for line in lines:
			self.parseLine(line)
		return self.output.getvalue()
Exemplo n.º 12
0
	def getCraftedGcode(self, gcodeText, repository):
		'Parse gcode text and store the dimension gcode.'
		self.repository = repository
		filamentRadius = 0.5 * repository.filamentDiameter.value
		filamentPackingArea = filamentRadius ** 2 * math.pi
		self.minimumTravelForRetraction = self.repository.minimumTravelForRetraction.value
		self.doubleMinimumTravelForRetraction = self.minimumTravelForRetraction + self.minimumTravelForRetraction
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		if not self.repository.retractWithinIsland.value:
			self.parseBoundaries()
		self.flowScaleSixty = ((self.edgeWidth-self.layerHeight)*self.layerHeight)+(self.layerHeight/2)**2* math.pi
		self.calibrationFactor = (4 * (-repository.filamentPackingDensityx.value))/((math.pi-4)*self.layerHeight+ 4* self.edgeWidth  )+1
		if self.operatingFlowRate is None:
			print('There is no operatingFlowRate so dimension will do nothing.')
			return gcodeText
#   Calculate the extrusion volume
		self.extrusionReduction = filamentPackingArea * self.calibrationFactor #todo comment out later
#   Retraction for fixed
		self.restartDistance = self.repository.retractionDistance.value + self.repository.restartExtraDistance.value
		self.extruderRetractionSpeedMinuteString = self.distanceFeedRate.getRounded(60.0 * self.repository.extruderRetractionSpeed.value)
		if self.maximumZFeedRatePerSecond != None and self.travelFeedRatePerSecond != None:
			self.zDistanceRatio = self.travelFeedRatePerSecond / self.maximumZFeedRatePerSecond
		for lineIndex in xrange(self.lineIndex, len(self.lines)):
			self.parseLine( lineIndex )
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 13
0
	def parseGcode( self, fileName, gcodeText, repository ):
		"Parse gcode text and store the vector output."
		self.fileName = fileName
		self.gcodeText = gcodeText
		self.repository = repository
		self.initializeActiveLocation()
		self.cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0)
		self.cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0)
		self.lines = archive.getTextLines(gcodeText)
		self.isThereALayerStartWord = (gcodec.getFirstWordIndexReverse('(<layer>', self.lines, 1) > -1)
		self.parseInitialization()
		for line in self.lines[self.lineIndex :]:
			self.parseCorner(line)
		self.cornerMaximumComplex = self.cornerMaximum.dropAxis()
		self.cornerMinimumComplex = self.cornerMinimum.dropAxis()
		self.scale = repository.scale.value
		self.scaleCornerHigh = self.scale * self.cornerMaximumComplex
		self.scaleCornerLow = self.scale * self.cornerMinimumComplex
		self.cornerImaginaryTotal = self.cornerMaximum.y + self.cornerMinimum.y
		self.margin = complex( 10.0, 10.0 )
		self.marginCornerHigh = self.scaleCornerHigh + self.margin
		self.marginCornerLow = self.scaleCornerLow - self.margin
		self.screenSize = self.marginCornerHigh - self.marginCornerLow
		self.initializeActiveLocation()
		self.colorNames = ['brown', 'red', 'orange', 'yellow', 'green', 'blue', 'purple']
		for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
Exemplo n.º 14
0
def getFirstValue(gcodeText, word):
	'Get the value from the first line which starts with the given word.'
	for line in archive.getTextLines(gcodeText):
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
		if gcodec.getFirstWord(splitLine) == word:
			return splitLine[1]
	return ''
Exemplo n.º 15
0
def getGcodeWithoutDuplication(duplicateWord, gcodeText):
	'Get gcode text without duplicate first words.'
	isExtruderActive = False
	lines = archive.getTextLines(gcodeText)
	oldDuplicationLine = None
	outputLines = []
	output = cStringIO.StringIO()
	for line in lines:
		firstWord = getFirstWordFromLine(line)
		if firstWord == duplicateWord:
			oldDuplicationLine = line
		else:
			if firstWord == 'M101':
				isExtruderActive = True
			elif firstWord == 'M103':
				isExtruderActive = False
			if isExtruderActive and oldDuplicationLine != None and firstWord.startswith('G'):
				outputLines.append(oldDuplicationLine)
				oldDuplicationLine = None
			if len(line) != 0:
				outputLines.append(line)
	if oldDuplicationLine != None:
		outputLines.append(oldDuplicationLine)
	oldWrittenLine = None
	for outputLine in outputLines:
		firstWord = getFirstWordFromLine(outputLine)
		if firstWord == duplicateWord:
			if outputLine != oldWrittenLine:
				output.write(outputLine + '\n')
				oldWrittenLine = outputLine
		else:
			output.write(outputLine + '\n')
	return output.getvalue()
Exemplo n.º 16
0
	def getCraftedGcode( self, gcodeText, repository ):
		"Parse gcode text and add the altshell gcode."
		self.repository = repository
		self.lines = archive.getTextLines( gcodeText )
		for line in self.lines:
			self.parseLine( line )
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 17
0
	def getCraftedGcode( self, repository, gcodeText ):
		'Parse gcode text and store the export gcode.'
		self.repository = repository
		lines = archive.getTextLines(gcodeText)
		for line in lines:
			self.parseLine(line)
		return self.output.getvalue()
Exemplo n.º 18
0
	def getCarvedSVG(self, fileName, gcodeText, repository):
		'Parse gnu triangulated surface text and store the vectorwrite gcode.'
		cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0)
		cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0)
		self.boundaryLoop = None
		self.extruderActive = False
		self.isLoop = False
		self.isOuter = False
		self.isPerimeter = False
		self.lines = archive.getTextLines(gcodeText)
		self.oldLocation = None
		self.thread = []
		self.threadLayers = []
		self.repository = repository
		self.parseInitialization()
		for line in self.lines[self.lineIndex :]:
			self.parseLine(line)
		self.removeEmptyLayers()
		for threadLayer in self.threadLayers:
			threadLayer.maximize(cornerMaximum)
			threadLayer.minimize(cornerMinimum)
		halfLayerThickness = 0.5 * self.layerThickness
		cornerMaximum.z += halfLayerThickness
		cornerMinimum.z -= halfLayerThickness
		svgWriter = SVGWriterVectorwrite(
			True, cornerMaximum, cornerMinimum, self.decimalPlacesCarried, self.layerThickness, self.perimeterWidth)
		return svgWriter.getReplacedSVGTemplate(fileName, 'vectorwrite', self.threadLayers)
Exemplo n.º 19
0
	def getCraftedGcode( self, gcodeStepRepository, gcodeText ):
		"Parse gcode text and store the gcode."
		self.gcodeStepRepository = gcodeStepRepository
		lines = archive.getTextLines(gcodeText)
		for line in lines:
			self.parseLine(line)
		return self.output.getvalue()
Exemplo n.º 20
0
	def addOriginalAsComment(self, xmlElement):
		'Add original xmlElement as a comment.'
		if xmlElement == None:
			return
		if xmlElement.className == 'comment':
			xmlElement.setParentAddToChildren(self.svgElement)
			return
		commentElement = xml_simple_reader.XMLElement()
		commentElement.className = 'comment'
		xmlElementOutput = cStringIO.StringIO()
		xmlElement.addXML(0, xmlElementOutput)
		textLines = archive.getTextLines(xmlElementOutput.getvalue())
		commentElementOutput = cStringIO.StringIO()
		isComment = False
		for textLine in textLines:
			lineStripped = textLine.strip()
			if lineStripped[: len('<!--')] == '<!--':
				isComment = True
			if not isComment:
				if len(textLine) > 0:
					commentElementOutput.write(textLine + '\n')
			if '-->' in lineStripped:
				isComment = False
		commentElement.text = '%s%s-->\n' % (globalOriginalTextString, commentElementOutput.getvalue())
		commentElement.setParentAddToChildren(self.svgElement)
Exemplo n.º 21
0
def getXMLLines(text):
	'Get the all the xml lines of a text.'
	accumulatedOutput = None
	textLines = archive.getTextLines(text)
	combinedLines = []
	lastWord = '>'
	for textLine in textLines:
		strippedLine = textLine.strip()
		firstCharacter = None
		lastCharacter = None
		if len( strippedLine ) > 1:
			firstCharacter = strippedLine[0]
			lastCharacter = strippedLine[-1]
		if firstCharacter == '<' and lastCharacter != '>' and accumulatedOutput == None:
			accumulatedOutput = cStringIO.StringIO()
			accumulatedOutput.write( textLine )
			if strippedLine[ : len('<!--') ] == '<!--':
				lastWord = '-->'
		else:
			if accumulatedOutput == None:
				addXMLLine( textLine, combinedLines )
			else:
				accumulatedOutput.write('\n' + textLine )
				if strippedLine[ - len( lastWord ) : ] == lastWord:
					addXMLLine( accumulatedOutput.getvalue(), combinedLines )
					accumulatedOutput = None
					lastWord = '>'
	xmlLines = []
	for combinedLine in combinedLines:
		xmlLines += getXMLTagSplitLines(combinedLine)
	return xmlLines
Exemplo n.º 22
0
def getNavigationHypertext(fileText, transferredFileNameIndex, transferredFileNames):
	'Get the hypertext help with navigation lines.'
	helpTextEnd = fileText.find('</p>')
	helpTextStart = fileText.find('<p>')
	helpText = fileText[helpTextStart : helpTextEnd]
	lines = archive.getTextLines(helpText)
	headings = []
	headingLineTable = {}
	for line in lines:
		addToHeadings(headingLineTable, headings, line)
	headingsToBeenAdded = True
	output = cStringIO.StringIO()
	for line in lines:
		if line[: 2] == '==':
			if headingsToBeenAdded:
				output.write('<br />\n')
				for heading in headings:
					heading.addToOutput(output)
				output.write('<br />\n')
				headingsToBeenAdded = False
			if line in headingLineTable:
				line = headingLineTable[line]
		if line.find('&lt;a href=') > -1:
			line = line.replace('&lt;', '<').replace('&gt;', '>')
		output.write(line + '\n')
	helpText = output.getvalue()
	previousFileName = 'contents.html'
	previousIndex = transferredFileNameIndex - 1
	if previousIndex >= 0:
		previousFileName = transferredFileNames[previousIndex]
	previousLinkText = '<a href="%s">Previous</a>' % previousFileName
	nextLinkText = getNextLinkText(transferredFileNames, transferredFileNameIndex + 1)
	navigationLine = getNavigationLine('<a href="contents.html">Contents</a>', previousLinkText, nextLinkText)
	helpText = navigationLine + helpText + '<br />\n<br />\n' + navigationLine + '<hr>\n'
	return fileText[: helpTextStart] + helpText + fileText[helpTextEnd :]
Exemplo n.º 23
0
def getHeightGrid(fileName):
	'Get heightGrid by fileName.'
	if 'models/' not in fileName:
		print('Warning, models/ was not in the absolute file path, so for security nothing will be done for:')
		print(fileName)
		print('The heightmap tool can only read a file which has models/ in the file path.')
		print('To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.')
		return
	pgmText = archive.getFileText(fileName)
	textLines = archive.getTextLines(pgmText)
	format = textLines[0].lower()
	sizeWords = textLines[2].split()
	numberOfColumns = int(sizeWords[0])
	numberOfRows = int(sizeWords[1])
	heights = []
	if format == 'p1':
		addHeightsByBitmap(heights, textLines)
	elif format == 'p2':
		addHeightsByGraymap(heights, textLines)
	else:
		print('Warning, the file format was not recognized for:')
		print(fileName)
		print('Heightmap can only read the Netpbm Portable bitmap format and the Netpbm Portable graymap format.')
		print('The Netpbm formats are described at:')
		print('http://en.wikipedia.org/wiki/Netpbm_format')
		return []
	heightGrid = []
	heightIndex = 0
	for rowIndex in xrange(numberOfRows):
		row = []
		heightGrid.append(row)
		for columnIndex in xrange(numberOfColumns):
			row.append(heights[heightIndex])
			heightIndex += 1
	return heightGrid
Exemplo n.º 24
0
def getGcodeWithoutDuplication(duplicateWord, gcodeText):
	'Get gcode text without duplicate first words.'
	lines = archive.getTextLines(gcodeText)
	oldWrittenLine = None
	output = cStringIO.StringIO()
	for line in lines:
		firstWord = getFirstWordFromLine(line)
		if firstWord == duplicateWord:
			if line != oldWrittenLine:
				output.write(line + '\n')
				oldWrittenLine = line
		else:
			if len(line) > 0:
				output.write(line + '\n')
	return output.getvalue() ###
	return gcodeText
	isExtruderActive = False
	lines = archive.getTextLines(gcodeText)
	oldDuplicationIndex = None
	oldWrittenLine = None
	output = cStringIO.StringIO()
	for lineIndex, line in enumerate(lines):
		firstWord = getFirstWordFromLine(line)
		if firstWord is duplicateWord:
			if oldDuplicationIndex is None:
				oldDuplicationIndex = lineIndex
			else:
				lines[oldDuplicationIndex] = line
				lines[lineIndex] = ''
		elif firstWord.startswith('G'):
			if isExtruderActive:
				oldDuplicationIndex = None
		elif firstWord == 'M101':
			isExtruderActive = True
			oldDuplicationIndex = None
		elif firstWord == 'M103':
			isExtruderActive = False
	for line in lines:
		firstWord = getFirstWordFromLine(line)
		if firstWord is duplicateWord:
			if line != oldWrittenLine:
				output.write(line + '\n')
				oldWrittenLine = line
		else:
			if len(line) > 0:
				output.write(line + '\n')
	return output.getvalue()
Exemplo n.º 25
0
 def parseGcode(self, fileName, gcodeText, repository):
     "Parse gcode text and store the vector output."
     self.repository = repository
     self.fileName = fileName
     self.gcodeText = gcodeText
     self.initializeActiveLocation()
     self.cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0)
     self.cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0)
     self.goAroundExtruderOffTravel = repository.goAroundExtruderOffTravel.value
     self.lines = archive.getTextLines(gcodeText)
     self.isThereALayerStartWord = gcodec.getFirstWordIndexReverse("(<layer>", self.lines, 1) > -1
     if self.isThereALayerStartWord:
         self.parseInitialization()
     else:
         print("")
         print("")
         print("")
         print(
             "Warning, there are no skeinforge comments in this text, probably because they have been removed by export."
         )
         print("So there is no loop information, and therefore the lines will not be colored.")
         print("")
         print("To see the full information in an exported file, either deselect Delete Comments in export, or")
         print(
             "select Save Penultimate Gcode in export, and open the generated file with the suffix _penultimate.gcode."
         )
         print("")
         print("")
         print("")
     for line in self.lines[self.lineIndex :]:
         self.parseCorner(line)
     self.oldZ = -999987654321.0
     if len(self.layerTops) > 0:
         self.layerTops[-1] += 912345678.9
     if len(self.layerTops) > 1:
         self.oneMinusBrightnessOverTopLayerIndex = (1.0 - repository.bottomLayerBrightness.value) / float(
             len(self.layerTops) - 1
         )
     self.firstTopLayer = len(self.layerTops) - self.repository.numberOfFillTopLayers.value
     self.centerComplex = 0.5 * (self.cornerMaximum.dropAxis() + self.cornerMinimum.dropAxis())
     self.centerBottom = Vector3(self.centerComplex.real, self.centerComplex.imag, self.cornerMinimum.z)
     self.scale = repository.scale.value
     self.scaleCenterBottom = self.scale * self.centerBottom
     self.scaleCornerHigh = self.scale * self.cornerMaximum.dropAxis()
     self.scaleCornerLow = self.scale * self.cornerMinimum.dropAxis()
     print(
         "The lower left corner of the skeiniso window is at %s, %s" % (self.cornerMinimum.x, self.cornerMinimum.y)
     )
     print(
         "The upper right corner of the skeiniso window is at %s, %s" % (self.cornerMaximum.x, self.cornerMaximum.y)
     )
     self.cornerImaginaryTotal = self.cornerMaximum.y + self.cornerMinimum.y
     margin = complex(5.0, 5.0)
     self.marginCornerLow = self.scaleCornerLow - margin
     self.screenSize = margin + 2.0 * (self.scaleCornerHigh - self.marginCornerLow)
     self.initializeActiveLocation()
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLine(line)
Exemplo n.º 26
0
def getGcodeTextWithoutRedundantMcode(gcodeText):
    'Get gcode text without redundant M104 and M108.'
    lines = archive.getTextLines(gcodeText)
    lines = getLinesWithoutRedundancy('M104', lines)
    lines = getLinesWithoutRedundancy('M108', lines)
    output = cStringIO.StringIO()
    gcodec.addLinesToCString(output, lines)
    return output.getvalue()
Exemplo n.º 27
0
 def getCraftedGcode(self, gcodeText, repository):
     'Parse gcode text and store the widen gcode.'
     self.repository = repository
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     for line in self.lines[self.lineIndex:]:
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 28
0
def addFacesGivenText( stlText, triangleMesh, vertexIndexTable ):
    "Add faces given stl text."
    lines = archive.getTextLines( stlText )
    vertexes = []
    for line in lines:
        if line.find('vertex') != - 1:
            vertexes.append( getVertexGivenLine(line) )
    addFacesGivenVertexes( triangleMesh, vertexIndexTable, vertexes )
Exemplo n.º 29
0
 def getCraftedGcode(self, gcodeText, repository):
     "Parse gcode text and store the bevel gcode."
     self.repository = repository
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     for lineIndex in xrange(self.lineIndex, len(self.lines)):
         self.parseLine(lineIndex)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 30
0
 def getCraftedGcode(self, whittleRepository, gcodeText):
     "Parse gcode text and store the whittle gcode."
     self.whittleRepository = whittleRepository
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     for line in self.lines[self.lineIndex:]:
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 31
0
	def getCraftedGcode( self, clipRepository, gcodeText ):
		"Parse gcode text and store the clip gcode."
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization( clipRepository )
		for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 32
0
def addFacesGivenText(stlText, triangleMesh, vertexIndexTable):
    "Add faces given stl text."
    lines = archive.getTextLines(stlText)
    vertexes = []
    for line in lines:
        if line.find("vertex") != -1:
            vertexes.append(getVertexGivenLine(line))
    addFacesGivenVertexes(triangleMesh, vertexIndexTable, vertexes)
Exemplo n.º 33
0
	def getCraftedGcode( self, clipRepository, gcodeText ):
		"Parse gcode text and store the clip gcode."
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization( clipRepository )
		for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 34
0
	def getCraftedGcode(self, gcodeText, repository):
		"Parse gcode text and store the bevel gcode."
		self.repository = repository
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		for line in self.lines[self.lineIndex :]:
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 35
0
	def getCraftedGcode(self, gcodeText, repository):
		'Parse gcode text and store the bevel gcode.'
		self.repository = repository
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		for lineIndex in xrange(self.lineIndex, len(self.lines)):
			self.parseLine( lineIndex )
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 36
0
def getGcodeTextWithoutRedundantMcode(gcodeText):
	'Get gcode text without redundant M104 and M108.'
	lines = archive.getTextLines(gcodeText)
	lines = getLinesWithoutRedundancy('M104', lines)
	lines = getLinesWithoutRedundancy('M108', lines)
	output = cStringIO.StringIO()
	gcodec.addLinesToCString(output, lines)
	return output.getvalue()
Exemplo n.º 37
0
	def __init__( self, parent, csvText ):
		"Add empty lists."
		self.continueFunction = None
		self.extraLeadingTabCount = None
		self.lines = archive.getTextLines( csvText )
		self.oldCSVElement = None
		self.root = None
		for line in self.lines:
			self.parseLine(line)
Exemplo n.º 38
0
	def getCraftedGcode( self, gcodeText, hopRepository ):
		"Parse gcode text and store the hop gcode."
		self.lines = archive.getTextLines(gcodeText)
		self.minimumSlope = math.tan( math.radians( hopRepository.minimumHopAngle.value ) )
		self.parseInitialization( hopRepository )
		for self.lineIndex in xrange( self.lineIndex, len(self.lines) ):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 39
0
 def getCraftedGcode(self, gcodeText, stretchRepository):
     "Parse gcode text and store the stretch gcode."
     self.lines = archive.getTextLines(gcodeText)
     self.stretchRepository = stretchRepository
     self.parseInitialization()
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseStretch(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 40
0
    def getCraftedGcode(self, gcodeText, repository):
        'Parse gcode text and store the dimension gcode.'
        self.repository = repository
        filamentRadius = 0.5 * repository.filamentDiameter.value
        filamentPackingArea = filamentRadius**2 * math.pi
        self.minimumTravelForRetraction = self.repository.minimumTravelForRetraction.value
        self.doubleMinimumTravelForRetraction = self.minimumTravelForRetraction + self.minimumTravelForRetraction
        self.lines = archive.getTextLines(gcodeText)
        self.parseInitialization()
        if not self.repository.retractWithinIsland.value:
            self.parseBoundaries()
        self.flowScaleSixty = (((self.layerHeight + self.edgeWidth) / 4) * (
            (self.layerHeight + self.edgeWidth) / 4)) * math.pi
        if repository.activateCalibration.value:
            self.calibrationFactor = (
                4 *
                (self.repository.MeasuredXSection.value - self.edgeWidth)) / (
                    (math.pi - 4) * self.layerHeight + 4 * self.edgeWidth) + 1
            self.newfilamentPackingDensity = repository.filamentPackingDensity.value * self.calibrationFactor
            print(
                '***************E-Steps corrector Value (For Calibration)*********************:'
            )
            print(
                '****E-Steps corrector Value (For Calibration) STEPPER EXTRUDERS ONLY :*******',
                self.newfilamentPackingDensity)
            print(
                '***************E-Steps corrector Value (For Calibration)*********************'
            )
            print(
                '**********this created G-CODE is only for calculating The Value**************'
            )
            print(
                '****Enter the Value into SFACT, uncheck the calibration box, RE-Skein********'
            )
        else:
            self.calibrationFactor = repository.filamentPackingDensity.value
        if self.calibrationFactor is None:
            print(
                'Measured extrusion width cant be 0, either un-check calibration or set measured width to what you have measured!'
            )
        if self.operatingFlowRate is None:
            print(
                'There is no operatingFlowRate so dimension will do nothing.')
            return gcodeText


#   Calculate the extrusion volume
        self.extrusionReduction = filamentPackingArea * self.calibrationFactor  #todo comment out later
        #   Retraction for fixed
        self.restartDistance = self.repository.retractionDistance.value + self.repository.restartExtraDistance.value
        self.extruderRetractionSpeedMinuteString = self.distanceFeedRate.getRounded(
            60.0 * self.repository.extruderRetractionSpeed.value)
        if self.maximumZFeedRatePerSecond != None and self.travelFeedRatePerSecond != None:
            self.zDistanceRatio = self.travelFeedRatePerSecond / self.maximumZFeedRatePerSecond
        for lineIndex in xrange(self.lineIndex, len(self.lines)):
            self.parseLine(lineIndex)
        return self.distanceFeedRate.output.getvalue()
Exemplo n.º 41
0
 def getCraftedGcode(self, repository, gcodeText):
     "Parse gcode text and store the bevel gcode."
     self.cornerFeedRateMultiplier = repository.cornerFeedRateMultiplier.value
     self.lines = archive.getTextLines(gcodeText)
     self.repository = repository
     self.parseInitialization(repository)
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 42
0
	def getCraftedGcode(self, gcodeText, repository):
		'Parse gcode text and store the limit gcode.'
		self.repository = repository
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		self.maximumZDrillFeedRatePerSecond = min(self.maximumZDrillFeedRatePerSecond, self.maximumZFeedRatePerSecond)
		self.maximumZCurrentFeedRatePerSecond = self.maximumZFeedRatePerSecond
		for lineIndex in xrange(self.lineIndex, len(self.lines)):
			self.parseLine( lineIndex )
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 43
0
	def getCraftedGcode( self, repository, gcodeText ):
		'Parse gcode text and store the export gcode.'
		self.repository = repository
		self.inPreface = True
		self.inInitialisation = False
		self.crafting = False
		lines = archive.getTextLines(gcodeText)
		for line in lines:
			self.parseLine(line)
		return self.output.getvalue()
Exemplo n.º 44
0
 def getCraftedGcode(self, gcodeText, repository):
     'Parse gcode text and store the smooth gcode.'
     self.lines = archive.getTextLines(gcodeText)
     self.repository = repository
     self.layersFromBottom = repository.layersFrom.value
     self.parseInitialization()
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 45
0
 def getCraftedGcode(self, gcodeText, repository):
     "Parse gcode text and store the coil gcode."
     self.repository = repository
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     self.parseBoundaries()
     self.parseUntilLayer()
     self.addCoilLayers()
     self.distanceFeedRate.addLines(self.shutdownLines)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 46
0
	def getCraftedGcode(self, jitterRepository, gcodeText):
		'Parse gcode text and store the jitter gcode.'
		if jitterRepository.jitterOverPerimeterWidth.value == 0.0:
			print('Warning, Jitter Over Perimeter Width is zero so thing will be done.')
			return gcodeText
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization(jitterRepository)
		for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
			self.parseLine(self.lines[self.lineIndex])
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 47
0
Arquivo: obj.py Projeto: folksjos/RepG
def addFacesGivenText(objText, triangleMesh):
    "Add faces given obj text."
    lines = archive.getTextLines(objText)
    for line in lines:
        splitLine = line.split()
        firstWord = gcodec.getFirstWord(splitLine)
        if firstWord == 'v':
            triangleMesh.vertexes.append(getVertexGivenLine(line))
        elif firstWord == 'f':
            triangleMesh.faces.append(getFaceGivenLine(line, triangleMesh))
Exemplo n.º 48
0
 def getCraftedGcode(self, gcodeText, repository):
     "Parse gcode text and store the feed gcode."
     self.repository = repository
     self.feedRatePerSecond = repository.feedRatePerSecond.value
     self.travelFeedRateMinute = 60.0 * self.repository.travelFeedRatePerSecond.value
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     for line in self.lines[self.lineIndex:]:
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 49
0
	def getReplacedAlterationText(self):
		'Replace the alteration lines if there are settings.'
		if self.settingDictionary == None:
			return self.distanceFeedRate.output.getvalue().replace('(<alterationDeleteThisPrefix/>)', '')
		lines = archive.getTextLines(self.distanceFeedRate.output.getvalue())
		distanceFeedRate = gcodec.DistanceFeedRate()
		for line in lines:
			if line.startswith('(<alterationDeleteThisPrefix/>)'):
				line = self.getReplacedAlterationLine(line[len('(<alterationDeleteThisPrefix/>)') :])
			distanceFeedRate.addLine(line)
		return distanceFeedRate.output.getvalue()
Exemplo n.º 50
0
 def getCraftedGcode(self, gcodeText, repository):
     "Parse gcode text and add the outline gcode."
     self.repository = repository
     self.wantsOutline = self.repository.activateOutline.value
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     self.getFirstLayerBoundingBox()
     #print( "First layer bounding box is ", self.minX, ",", self.minY, " - ", self.maxX, ",", self.maxY, " at Z", self.firstZ, ", selected F", self.firstFeed )
     for line in self.lines[self.lineIndex:]:
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 51
0
	def getCraftedGcode(self, gcodeText, repository):
		"Parse gcode text and store the speed gcode."
		self.repository = repository
		self.feedRatePerSecond = repository.feedRatePerSecond.value
		self.travelFeedRateMinute = 60.0 * self.repository.travelFeedRatePerSecond.value
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		for line in self.lines[self.lineIndex :]:
			self.parseLine(line)
		self.addParameterString('M113', self.repository.dutyCycleAtEnding.value ) # Set duty cycle .
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 52
0
 def getCraftedGcode(self, gcodeText, lashRepository):
     "Parse gcode text and store the lash gcode."
     self.lines = archive.getTextLines(gcodeText)
     self.lashRepository = lashRepository
     self.xBacklash = lashRepository.xBacklash.value
     self.yBacklash = lashRepository.yBacklash.value
     self.parseInitialization()
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLash(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 53
0
	def getCraftedGcode(self, gcodeText, repository):
		'Parse gcode text and store the skirt gcode.'
		self.repository = repository
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		self.parseBoundaries()
		self.createSkirtLoops()
		for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
		return gcodec.getGcodeWithoutDuplication('M108', self.distanceFeedRate.output.getvalue())
Exemplo n.º 54
0
def getReplaced( exportText ):
	"Get text with strings replaced according to replace.csv file."
	replaceText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), 'Replace.csv')
	if replaceText == '':
		return exportText
	lines = archive.getTextLines( replaceText )
	for line in lines:
		splitLine = line.split('\t')
		if len(splitLine) > 1:
			exportText = exportText.replace( splitLine[0], splitLine[1] )
	return exportText
Exemplo n.º 55
0
 def getCraftedGcode(self, gcodeText, repository):
     "Parse gcode text and store the chamber gcode."
     endAtLeastBegin = repository.bedTemperatureEndChangeHeight.value >= repository.bedTemperatureBeginChangeHeight.value
     if endAtLeastBegin and repository.bedTemperatureBeginChangeHeight.value >= 0.0:
         self.changeWidth = repository.bedTemperatureEndChangeHeight.value - repository.bedTemperatureBeginChangeHeight.value
     self.repository = repository
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     for line in self.lines[self.lineIndex:]:
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 56
0
	def getCraftedGcode( self, gcodeText, repository ):
		"Parse gcode text and store the home gcode."
		self.repository = repository
		self.homeLines = settings.getAlterationFileLines(repository.nameOfHomeFile.value)
		if len(self.homeLines) < 1:
			return gcodeText
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization( repository )
		for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
			line = self.lines[self.lineIndex]
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 57
0
	def getCraftedGcode(self, gcodeText, repository):
		'Parse gcode text and store the multiply gcode.'
		self.centerOffset = complex(repository.centerX.value, repository.centerY.value)
		self.repository = repository
		self.numberOfColumns = repository.numberOfColumns.value
		self.numberOfRows = repository.numberOfRows.value
		self.lines = archive.getTextLines(gcodeText)
		self.parseInitialization()
		self.setCorners()
		for line in self.lines[self.lineIndex :]:
			self.parseLine(line)
		return self.distanceFeedRate.output.getvalue()
Exemplo n.º 58
0
def getReplaceableExportGcode(nameOfReplaceFile, replaceableExportGcode):
	'Get text with strings replaced according to replace.csv file.'
	replaceLines = settings.getAlterationLines(nameOfReplaceFile)
	if len(replaceLines) < 1:
		return replaceableExportGcode
	for replaceLine in replaceLines:
		splitLine = replaceLine.replace('\n', '\t').split('\t')
		if len(splitLine) > 0:
			replaceableExportGcode = replaceableExportGcode.replace(splitLine[0], '\n'.join(splitLine[1 :]))
	output = cStringIO.StringIO()
	gcodec.addLinesToCString(output, archive.getTextLines(replaceableExportGcode))
	return output.getvalue()
Exemplo n.º 59
0
 def getCraftedGcode(self, gcodeText, repository):
     "Parse gcode text and store the unpause gcode."
     self.delaySecond = repository.delay.value * 0.001
     self.maximumSpeed = repository.maximumSpeed.value
     self.minimumSpeedUpReciprocal = 1.0 / self.maximumSpeed
     self.repository = repository
     self.lines = archive.getTextLines(gcodeText)
     self.parseInitialization()
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         self.parseLine(line)
     return self.distanceFeedRate.output.getvalue()
Exemplo n.º 60
0
    def getCraftedGcode(self, gcodeText, repository):
        'Parse gcode text and store the dimension gcode.'
        self.repository = repository
        filamentRadius = 0.5 * repository.filamentDiameter.value
        xSectionCorrector = repository.MeasuredXSection.value
        filamentPackingArea = math.pi * filamentRadius * filamentRadius * repository.filamentPackingDensity.value
        #self.minimumExtrusionForRetraction = 0 #self.repository.minimumExtrusionForRetraction.value
        #self.minimumTravelForRetraction = 0 # self.repository.minimumTravelForRetraction.value
        self.doubleMinimumTravelForRetraction = 0  #self.minimumTravelForRetraction + self.minimumTravelForRetraction
        self.lines = archive.getTextLines(gcodeText)
        self.parseInitialization()
        #if self.repository.retractWhenCrossing.value:
        self.parseBoundaries()
        self.calibrationFactor = 1
        if repository.activateCalibration.value:
            self.calibrationFactor = (
                ((self.layerThickness**2 / 4) * math.pi) +
                self.layerThickness *
                (xSectionCorrector - self.layerThickness)) / (
                    ((self.layerThickness**2 / 4) * math.pi) +
                    self.layerThickness *
                    (self.perimeterWidth - self.layerThickness))
        self.newfilamentPackingDensity = repository.filamentPackingDensity.value * self.calibrationFactor
        print(
            '****************Filament Packing Density (For Calibration)**********************:'
        )
        print(
            'Filament Packing Density (For Calibration) STEPPER EXTRUDERS ONLY :',
            self.newfilamentPackingDensity)
        print(
            '****************Filament Packing Density (For Calibration)**********************'
        )
        self.flowScaleSixty = 60.0 * (
            (((self.layerThickness + self.perimeterWidth) / 4)**2 * math.pi) /
            filamentPackingArea) / self.calibrationFactor
        #print ('filamentPackingArea self.calibrationFactor',filamentPackingArea ,self.calibrationFactor)
        if self.calibrationFactor is None:
            print(
                'Measured extrusion width cant be 0, either un-check calibration or set measured width to what you have measured!'
            )
        if self.operatingFlowRate == None:
            print(
                'There is no operatingFlowRate so dimension will do nothing.')
            return gcodeText
#		self.restartDistance = self.autoRetractDistance #self.repository.retractionDistance.value# + (self.repository.restartExtraDistance.value) *self.autoRetractDistance
#		((self.restartDistance * self.retractionRatio) - (self.restartDistance * self.retractionRatio)* self.autoRetractDistance)
        self.extruderRetractionSpeedMinuteString = self.distanceFeedRate.getRounded(
            60.0 * self.repository.extruderRetractionSpeed.value)
        if self.maximumZTravelFeedRatePerSecond != None and self.travelFeedRatePerSecond != None:
            self.zDistanceRatio = self.travelFeedRatePerSecond / self.maximumZTravelFeedRatePerSecond
        for lineIndex in xrange(self.lineIndex, len(self.lines)):
            self.parseLine(lineIndex)
        return self.distanceFeedRate.output.getvalue()