def readPreferences( archivablePreferences ): "Set an archive to the preferences read from a file." text = gcodec.getFileText( archivablePreferences.fileNamePreferences ) if text == '': print( 'Since the preferences file:' ) print( archivablePreferences.fileNamePreferences ) print( 'does not exist, the default preferences will be written to that file.' ) text = gcodec.getFileText( os.path.join( 'defaults', os.path.basename( archivablePreferences.fileNamePreferences ) ) ) if text != '': readPreferencesFromText( archivablePreferences, text ) writePreferences( archivablePreferences ) return readPreferencesFromText( archivablePreferences, text )
def writeOutput(fileName, gcodeText=''): "Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected." repository = settings.getReadRepository(CommentRepository()) if gcodeText == '': gcodeText = gcodec.getFileText(fileName) if repository.activateComment.value: analyzeFileGivenText(fileName, gcodeText)
def writeOutput( fileName, gcodeText = '' ): "Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected." repository = settings.getReadRepository( StatisticRepository() ) if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) if repository.activateStatistic.value: analyzeFileGivenText( fileName, gcodeText, repository )
def getCraftedText(fileName, text="", repository=None): "Get chopped text." if gcodec.getHasSuffix(fileName, ".svg"): if text == "": text = gcodec.getFileText(fileName) return text return getCraftedTextFromFileName(fileName, repository=None)
def getCarving(fileName=''): "Get the triangle mesh for the stl file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords('stl') if len(unmodified) == 0: print("There is no stl file in this folder.") return None fileName = unmodified[0] stlData = gcodec.getFileText(fileName, 'rb') if stlData == '': return None triangleMesh = triangle_mesh.TriangleMesh() vertexIndexTable = {} binarySolidworksHeaderErrorString = 'solid binary STL from Solid Edge, Unigraphics Solutions Inc.' binarySolidworksHeaderError = stlData[:len( binarySolidworksHeaderErrorString )] == binarySolidworksHeaderErrorString if binarySolidworksHeaderError: print('The solidworks file has the incorrect header:') print(binarySolidworksHeaderErrorString) print( 'A binary stl should never start with the word "solid". Because this error is common the file is been parsed as binary regardless.' ) if (stlData[:5] == 'solid' and not binarySolidworksHeaderError): addFacesGivenText(stlData, triangleMesh, vertexIndexTable) else: addFacesGivenBinary(stlData, triangleMesh, vertexIndexTable) triangleMesh.setEdgesForAllFaces() return triangleMesh
def getCraftedText(fileName, text='', repository=None): "Get cleaved text." if gcodec.getHasSuffix(fileName, '.svg'): if text == '': text = gcodec.getFileText(fileName) return text return getCraftedTextFromFileName(fileName, repository=None)
def getCarving( fileName = '' ): "Get the triangle mesh for the stl file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'stl' ) if len( unmodified ) == 0: print( "There is no stl file in this folder." ) return None fileName = unmodified[ 0 ] stlData = gcodec.getFileText( fileName, 'rb' ) if stlData == '': return None triangleMesh = triangle_mesh.TriangleMesh() vertexIndexTable = {} binarySolidworksHeaderErrorString = 'solid binary STL from Solid Edge, Unigraphics Solutions Inc.' binarySolidworksHeaderError = stlData[ : len( binarySolidworksHeaderErrorString ) ] == binarySolidworksHeaderErrorString if binarySolidworksHeaderError: print( 'The solidworks file has the incorrect header:' ) print( binarySolidworksHeaderErrorString ) print( 'A binary stl should never start with the word "solid". Because this error is common the file is been parsed as binary regardless.' ) if ( stlData[ : 5 ] == 'solid' and not binarySolidworksHeaderError ): addFacesGivenText( stlData, triangleMesh, vertexIndexTable ) else: addFacesGivenBinary( stlData, triangleMesh, vertexIndexTable ) triangleMesh.setEdgesForAllFaces() return triangleMesh
def writeOutput( fileName, gcodeText = '' ): "Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected." repository = settings.getReadRepository( CommentRepository() ) if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) if repository.activateComment.value: analyzeFileGivenText( fileName, gcodeText )
def getCraftedText( fileName, text = '', chopPreferences = None ): "Get chopped text." if gcodec.getHasSuffix( fileName, '.svg' ): if text == '': text = gcodec.getFileText( fileName ) return text return getCraftedTextFromFileName( fileName, chopPreferences = None )
def getCraftedText( fileName, text = '', repository = None ): "Get cleaved text." if gcodec.getHasSuffix( fileName, '.svg' ): if text == '': text = gcodec.getFileText( fileName ) return text return getCraftedTextFromFileName( fileName, repository = None )
def writeOutput(fileName, gcodeText=''): "Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected." repository = settings.getReadRepository(StatisticRepository()) if gcodeText == '': gcodeText = gcodec.getFileText(fileName) if repository.activateStatistic.value: analyzeFileGivenText(fileName, gcodeText, repository)
def addInitializationToOutput( self ): "Add initialization gcode to the output." self.addFromUpperLowerFile( self.prefacePreferences.nameOfStartFile.value ) # Add a start file if it exists. self.distanceFeedRate.addTagBracketedLine( 'creator', 'skeinforge' ) # GCode formatted comment absoluteFilePathUntilDot = os.path.abspath( __file__ )[ : os.path.abspath( __file__ ).rfind( '.' ) ] if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/craft_plugins/preface': #check to see if this script is on Enrique's computer gcodec.writeFileText( gcodec.getVersionFileName(), date.today().isoformat() ) versionText = gcodec.getFileText( gcodec.getVersionFileName() ) self.distanceFeedRate.addTagBracketedLine( 'version', versionText ) # GCode formatted comment self.distanceFeedRate.addLine( '(<extruderInitialization>)' ) # GCode formatted comment if self.prefacePreferences.setPositioningToAbsolute.value: self.distanceFeedRate.addLine( 'G90' ) # Set positioning to absolute. if self.prefacePreferences.setUnitsToMillimeters.value: self.distanceFeedRate.addLine( 'G21' ) # Set units to millimeters. if self.prefacePreferences.startAtHome.value: self.distanceFeedRate.addLine( 'G28' ) # Start at home. if self.prefacePreferences.turnExtruderOffAtStartUp.value: self.distanceFeedRate.addLine( 'M103' ) # Turn extruder off. self.distanceFeedRate.addTagBracketedLine( 'decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried ) if self.prefacePreferences.extrusionDistanceAbsolutePreference.value: self.distanceFeedRate.extrusionDistanceFormat = 'absolute' if self.prefacePreferences.extrusionDistanceRelativePreference.value: self.distanceFeedRate.extrusionDistanceFormat = 'relative' if self.distanceFeedRate.extrusionDistanceFormat != '': self.distanceFeedRate.addTagBracketedLine( 'extrusionDistanceFormat', self.distanceFeedRate.extrusionDistanceFormat ) self.distanceFeedRate.addTagBracketedLine( 'layerThickness', self.distanceFeedRate.getRounded( self.layerThickness ) ) self.distanceFeedRate.addTagBracketedLine( 'perimeterWidth', self.distanceFeedRate.getRounded( self.perimeterWidth ) ) self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'carve' ) self.distanceFeedRate.addTagBracketedLine( 'procedureDone', 'preface' ) self.distanceFeedRate.addLine( '(</extruderInitialization>)' ) # Initialization is finished, extrusion is starting. self.distanceFeedRate.addLine( '(<extrusion>)' ) # Initialization is finished, extrusion is starting.
def writeOutput( fileName, gcodeText = '' ): "Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected." commentPreferences = CommentPreferences() preferences.getReadRepository( commentPreferences ) if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) if commentPreferences.activateComment.value: writeCommentFileGivenText( fileName, gcodeText )
def readWriteDeleteHypertextHelp( documentDirectoryPath, fileName ): "Read the pydoc hypertext help documents, write them in the documentation folder then delete the originals." print( fileName ) filePath = os.path.join( documentDirectoryPath, fileName ) fileText = gcodec.getFileText( fileName ) fileText = getWrappedHypertext( fileText ) gcodec.writeFileText( filePath, fileText ) os.remove( fileName )
def writeOutput(fileName, gcodeText=''): "Write a commented gcode file for a skeinforge gcode file, if 'Write Commented File for Skeinforge Chain' is selected." commentPreferences = CommentPreferences() preferences.readPreferences(commentPreferences) if gcodeText == '': gcodeText = gcodec.getFileText(fileName) if commentPreferences.activateComment.value: writeCommentFileGivenText(fileName, gcodeText)
def getInsetChainGcode( fileName, gcodeText, insetPreferences = None ): "Inset the carves of a gcode text. Chain inset the gcode if it is not already carved." if gcodeText == '': if fileName[ - len( '.svg' ) : ] == '.svg': gcodeText = gcodec.getFileText( fileName ) if not gcodec.isProcedureDone( gcodeText, '"carve"' ): #"carve" is used instead of carve because quotes have to be used for strings in svg files gcodeText = carve.getCarveGcode( fileName ) return getInsetGcode( gcodeText, insetPreferences )
def writeOutput( fileName, gcodeText = '' ): "Write a skeinviewed gcode file for a skeinforge gcode file, if 'Activate Skeinview' is selected." skeinviewPreferences = SkeinviewPreferences() preferences.readPreferences( skeinviewPreferences ) if skeinviewPreferences.activateSkeinview.value: if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) displaySkeinviewFileGivenText( gcodeText, skeinviewPreferences )
def writeOutput( fileName, gcodeText = '' ): "Write a beholded gcode file for a skeinforge gcode file, if 'Activate Behold' is selected." beholdPreferences = BeholdPreferences() preferences.readPreferences( beholdPreferences ) if beholdPreferences.activateBehold.value: if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) displayBeholdFileGivenText( gcodeText, beholdPreferences )
def readWriteNavigationHelp( documentDirectoryPath, transferredFileNameIndex, transferredFileNames ): "Read the hypertext help documents, and add the navigation lines to them." fileName = transferredFileNames[ transferredFileNameIndex ] print( fileName ) filePath = os.path.join( documentDirectoryPath, fileName ) fileText = gcodec.getFileText( filePath ) fileText = getNavigationHypertext( fileText, transferredFileNameIndex, transferredFileNames ) gcodec.writeFileText( filePath, fileText )
def writeOutput( fileName, gcodeText = '' ): "Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected." statisticPreferences = StatisticPreferences() preferences.readPreferences( statisticPreferences ) if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) if statisticPreferences.activateStatistic.value: writeStatisticFileGivenText( fileName, gcodeText, statisticPreferences )
def writeOutput( fileName, gcodeText = '' ): "Write scalable vector graphics for a skeinforge gcode file, if 'Write Scalable Vector Graphics for Skeinforge Chain' is selected." vectorwritePreferences = VectorwritePreferences() preferences.readPreferences( vectorwritePreferences ) if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) if vectorwritePreferences.activateVectorwrite.value: writeVectorFileGivenText( fileName, gcodeText, vectorwritePreferences )
def writeOutput( fileName, gcodeText = '' ): "Write statistics for a skeinforge gcode file, if 'Write Statistics File for Skeinforge Chain' is selected." statisticPreferences = StatisticPreferences() preferences.getReadPreferences( statisticPreferences ) if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) if statisticPreferences.activateStatistic.value: writeStatisticFileGivenText( fileName, gcodeText, statisticPreferences )
def commentFile( fileName = '' ): "Comment a gcode file. If no fileName is specified, comment the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] writeCommentFileGivenText( fileName, gcodec.getFileText( fileName ) )
def getCarving( fileName = '' ): "Get the triangle mesh for the gts file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'gts' ) if len( unmodified ) == 0: print( "There is no gts file in this folder." ) return None fileName = unmodified[ 0 ] return getFromGNUTriangulatedSurfaceText( gcodec.getFileText( fileName ), triangle_mesh.TriangleMesh() )
def getCarving( fileName = '' ): "Get the triangle mesh for the gts file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'gts' ) if len( unmodified ) == 0: print( "There is no gts file in this folder." ) return None fileName = unmodified[ 0 ] return getFromGNUTriangulatedSurfaceText( gcodec.getFileText( fileName ), triangle_mesh.TriangleMesh() )
def commentFile(fileName=''): "Comment a gcode file. If no fileName is specified, comment the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len(unmodified) == 0: print("There are no unmodified gcode files in this folder.") return fileName = unmodified[0] writeCommentFileGivenText(fileName, gcodec.getFileText(fileName))
def readPreferences(archivablePreferences): "Set an archive to the preferences read from a file." text = gcodec.getFileText(archivablePreferences.fileNamePreferences) if text == '': print('Since the preferences file:') print(archivablePreferences.fileNamePreferences) print( 'does not exist, the default preferences will be written to that file.' ) text = gcodec.getFileText( os.path.join( 'defaults', os.path.basename(archivablePreferences.fileNamePreferences))) if text != '': readPreferencesFromText(archivablePreferences, text) writePreferences(archivablePreferences) else: readPreferencesFromText(archivablePreferences, text) applyPreferencesOverrides(archivablePreferences)
def getInsetChainGcode(fileName, gcodeText, insetPreferences=None): "Inset the carves of a gcode text. Chain inset the gcode if it is not already carved." if gcodeText == '': if fileName[-len('.svg'):] == '.svg': gcodeText = gcodec.getFileText(fileName) if not gcodec.isProcedureDone( gcodeText, '"carve"' ): #"carve" is used instead of carve because quotes have to be used for strings in svg files gcodeText = carve.getCarveGcode(fileName) return getInsetGcode(gcodeText, insetPreferences)
def beholdFile( fileName = '' ): "Behold a gcode file. If no fileName is specified, behold the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] gcodeText = gcodec.getFileText( fileName ) displayBeholdFileGivenText( gcodeText )
def getCarving( fileName = '' ): "Get the carving for the xml file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'xml' ) if len( unmodified ) == 0: print( "There is no xml file in this folder." ) return None fileName = unmodified[ 0 ] carving = XMLCarving() carving.parseXML( gcodec.getFileText( fileName ) ) return carving
def getCarving(fileName=""): "Get the triangle mesh for the gts file." if fileName == "": unmodified = gcodec.getFilesWithFileTypeWithoutWords("gts") if len(unmodified) == 0: print("There is no gts file in this folder.") return None fileName = unmodified[0] carving = SVGCarving() carving.parseSVG(gcodec.getFileText(fileName)) return carving
def statisticFile( fileName = '' ): "Write statistics for a gcode file. If no fileName is specified, write statistics for the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] statisticPreferences = StatisticPreferences() preferences.getReadPreferences( statisticPreferences ) writeStatisticFileGivenText( fileName, gcodec.getFileText( fileName ), statisticPreferences )
def getCarving(fileName=''): "Get the triangle mesh for the gts file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords('gts') if len(unmodified) == 0: print("There is no gts file in this folder.") return None fileName = unmodified[0] carving = SVGCarving() carving.parseSVG(gcodec.getFileText(fileName)) return carving
def statisticFile( fileName = '' ): "Write statistics for a gcode file. If no fileName is specified, write statistics for the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] statisticPreferences = StatisticPreferences() preferences.readPreferences( statisticPreferences ) writeStatisticFileGivenText( fileName, gcodec.getFileText( fileName ), statisticPreferences )
def writeVectorFile( fileName = '' ): "Write scalable vector graphics for a gcode file. If no fileName is specified, write scalable vector graphics for the first gcode file in this folder." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There is no gcode file in this folder." ) return fileName = unmodified[ 0 ] vectorwritePreferences = VectorwritePreferences() preferences.readPreferences( vectorwritePreferences ) gcodeText = gcodec.getFileText( fileName ) writeVectorFileGivenText( fileName, gcodeText, vectorwritePreferences )
def readWriteDeleteHypertextHelp( documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames ): "Read the pydoc hypertext help documents, write them in the documentation folder then delete the originals." fileName = hypertextFiles[ hypertextFileIndex ] print( fileName ) filePath = os.path.join( documentDirectoryPath, fileName ) fileText = gcodec.getFileText( fileName ) fileText = getWrappedHypertext( fileText, hypertextFileIndex, hypertextFiles ) if fileText.find( 'This page is in the table of contents.' ) > - 1: fileText = fileText.replace( 'This page is in the table of contents.', '' ) transferredFileNames.append( fileName ) gcodec.writeFileText( filePath, fileText ) os.remove( fileName )
def getTriangleMesh( fileName = '' ): "Carve a GNU Triangulated Surface file. If no fileName is specified, carve the first GNU Triangulated Surface file in this folder." if fileName == '': unmodified = gcodec.getGNUTriangulatedSurfaceFiles() if len( unmodified ) == 0: print( "There are no GNU Triangulated Surface files in this folder." ) return None fileName = unmodified[ 0 ] gnuTriangulatedSurfaceText = gcodec.getFileText( fileName ) if gnuTriangulatedSurfaceText == '': return None triangleMesh = TriangleMesh().getFromGNUTriangulatedSurfaceText( gnuTriangulatedSurfaceText ) return triangleMesh
def __init__( self ): "Set the default settings, execute title & settings fileName." settings.addListsToRepository( 'skeinforge.html', '', self ) self.fileNameInput = settings.FileNameInput().getFromFileName( interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Skeinforge', self, '' ) versionText = gcodec.getFileText( gcodec.getVersionFileName() ) self.createdOnLabel = settings.LabelDisplay().getFromName( 'Created On: ' + versionText, self ) self.profileType = settings.MenuButtonDisplay().getFromName( 'Profile Type: ', self ) self.profileSelection = settings.MenuButtonDisplay().getFromName( 'Profile Selection: ', self ) addToProfileMenu( self.profileSelection, self.profileType, self ) settings.LabelDisplay().getFromName( '', self ) self.skeinforgeLabel = settings.LabelDisplay().getFromName( 'Open Settings: ', self ) importantFileNames = [ 'craft', 'profile' ] settings.getDisplayToolButtonsRepository( gcodec.getAbsoluteFolderPath( __file__, 'skeinforge_tools' ), importantFileNames, getPluginFileNames(), self ) self.executeTitle = 'Skeinforge'
def addInitializationToOutput(self): "Add initialization gcode to the output." self.addFromUpperLowerFile(self.prefaceRepository.nameOfStartFile.value ) # Add a start file if it exists. self.distanceFeedRate.addTagBracketedLine( 'creator', 'skeinforge') # GCode formatted comment absoluteFilePathUntilDot = os.path.abspath( __file__)[:os.path.abspath(__file__).rfind('.')] if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/craft_plugins/preface': #check to see if this script is on Enrique's computer gcodec.writeFileText(gcodec.getVersionFileName(), date.today().isoformat()) versionText = gcodec.getFileText(gcodec.getVersionFileName()) self.distanceFeedRate.addTagBracketedLine( 'version', versionText) # GCode formatted comment self.distanceFeedRate.addLine( '(<extruderInitialization>)') # GCode formatted comment if self.prefaceRepository.setPositioningToAbsolute.value: self.distanceFeedRate.addLine( 'G90') # Set positioning to absolute. if self.prefaceRepository.setUnitsToMillimeters.value: self.distanceFeedRate.addLine('G21') # Set units to millimeters. if self.prefaceRepository.startAtHome.value: self.distanceFeedRate.addLine('G28') # Start at home. if self.prefaceRepository.turnExtruderOffAtStartUp.value: self.distanceFeedRate.addLine('M103') # Turn extruder off. craftTypeName = profile.getCraftTypeName() self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName) self.distanceFeedRate.addTagBracketedLine( 'decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried) self.distanceFeedRate.addTagBracketedLine( 'layerThickness', self.distanceFeedRate.getRounded(self.layerThickness)) if self.prefaceRepository.meta.value: self.distanceFeedRate.addTagBracketedLine( 'meta', self.prefaceRepository.meta.value) self.distanceFeedRate.addTagBracketedLine( 'perimeterWidth', self.distanceFeedRate.getRounded(self.perimeterWidth)) self.distanceFeedRate.addTagBracketedLine( 'profileName', profile.getProfileName(craftTypeName)) self.distanceFeedRate.addTagBracketedLine('procedureDone', 'carve') self.distanceFeedRate.addTagBracketedLine('procedureDone', 'preface') self.distanceFeedRate.addLine( '(</extruderInitialization>)' ) # Initialization is finished, extrusion is starting. self.distanceFeedRate.addLine( '(<extrusion>)' ) # Initialization is finished, extrusion is starting.
def getCarving( fileName = '' ): "Get the triangle mesh for the obj file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'obj' ) if len( unmodified ) == 0: print( "There is no obj file in this folder." ) return None fileName = unmodified[ 0 ] objText = gcodec.getFileText( fileName, 'rb' ) if objText == '': return None triangleMesh = triangle_mesh.TriangleMesh() addFacesGivenText( objText, triangleMesh ) triangleMesh.setEdgesForAllFaces() return triangleMesh
def getCarving(fileName=''): "Get the triangle mesh for the obj file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords('obj') if len(unmodified) == 0: print("There is no obj file in this folder.") return None fileName = unmodified[0] objText = gcodec.getFileText(fileName, 'rb') if objText == '': return None triangleMesh = triangle_mesh.TriangleMesh() addFacesGivenText(objText, triangleMesh) triangleMesh.setEdgesForAllFaces() return triangleMesh
def bevelFile( fileName = '' ): "Bevel a gcode linear move file. If no fileName is specified, bevel the first unmodified gcode file in this folder." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] filletPreferences = FilletPreferences() preferences.readPreferences( filletPreferences ) print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being beveled.' ) gcodeText = gcodec.getFileText( fileName ) if gcodeText == '': return gcodec.writeFileMessageSuffix( fileName, getBevelGcode( filletPreferences, gcodeText ), 'The beveled file is saved as ', '_fillet' )
def arcRadiusFile( fileName = '' ): "Fillet a gcode linear move file into a helical radius move file. If no fileName is specified, arc radius the first unmodified gcode file in this folder." if fileName == '': unmodified = gcodec.getUnmodifiedGCodeFiles() if len( unmodified ) == 0: print( "There are no unmodified gcode files in this folder." ) return fileName = unmodified[ 0 ] filletPreferences = FilletPreferences() preferences.readPreferences( filletPreferences ) print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being filleted into arc radiuses.' ) gcodeText = gcodec.getFileText( fileName ) if gcodeText == '': return gcodec.writeFileMessageSuffix( fileName, getArcRadiusGcode( filletPreferences, gcodeText ), 'The arc radius file is saved as ', '_fillet' )
def writeOutput( fileName = '', gcodeText = '' ): "Analyze a gcode file. If no fileName is specified, comment the first gcode file in this folder that is not modified." if fileName == '': unmodified = gcodec.getUncommentedGcodeFiles() if len( unmodified ) == 0: print( "There is no gcode file in this folder that is not a comment file." ) return fileName = unmodified[ 0 ] if gcodeText == '': gcodeText = gcodec.getFileText( fileName ) analyzePluginFilenames = getAnalyzePluginFilenames() for analyzePluginFilename in analyzePluginFilenames: pluginModule = gcodec.getModule( analyzePluginFilename, 'analyze_plugins', __file__ ) if pluginModule != None: pluginModule.writeOutput( fileName, gcodeText )
def getCarving( fileName = '' ): "Get the triangle mesh for the stl file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'stl' ) if len( unmodified ) == 0: print( "There is no stl file in this folder." ) return None fileName = unmodified[ 0 ] stlData = gcodec.getFileText( fileName, 'rb' ) if stlData == '': return None triangleMesh = triangle_mesh.TriangleMesh() vertexIndexTable = {} numberOfVertexStrings = stlData.count( 'vertex' ) requiredVertexStringsForText = max( 2, len( stlData ) / 8000 ) if numberOfVertexStrings > requiredVertexStringsForText: addFacesGivenText( stlData, triangleMesh, vertexIndexTable ) else: # A binary stl should never start with the word "solid". Because this error is common the file is been parsed as binary regardless. addFacesGivenBinary( stlData, triangleMesh, vertexIndexTable ) triangleMesh.setEdgesForAllFaces() return triangleMesh
def __init__(self): "Set the default settings, execute title & settings fileName." settings.addListsToRepository('skeinforge.html', '', self) self.fileNameInput = settings.FileNameInput().getFromFileName( interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Skeinforge', self, '') versionText = gcodec.getFileText(gcodec.getVersionFileName()) self.createdOnLabel = settings.LabelDisplay().getFromName( 'Created On: ' + versionText, self) self.profileType = settings.MenuButtonDisplay().getFromName( 'Profile Type: ', self) self.profileSelection = settings.MenuButtonDisplay().getFromName( 'Profile Selection: ', self) addToProfileMenu(self.profileSelection, self.profileType, self) settings.LabelDisplay().getFromName('', self) self.skeinforgeLabel = settings.LabelDisplay().getFromName( 'Open Settings: ', self) importantFileNames = ['craft', 'profile'] settings.getDisplayToolButtonsRepository( gcodec.getAbsoluteFolderPath(__file__, 'skeinforge_tools'), importantFileNames, getPluginFileNames(), self) self.executeTitle = 'Skeinforge'
def displayFile( filename ): "Parse a gcode file and display the commands." print( 'File ' + filename + ' is being displayed.' ) fileText = gcodec.getFileText( filename ) gcodec.writeFileMessageSuffix( filename, displayText( fileText ), 'The gcode log file is saved as ', '_log' )
def getFileTextGivenDirectoryFileName(directory, fileName): "Get the entire text of a file with the given file name in the given directory." absoluteFilePath = os.path.join(directory, fileName) return gcodec.getFileText(absoluteFilePath)
def analyzeFile(fileName): "Write scalable vector graphics for a gcode file." gcodeText = gcodec.getFileText(fileName) analyzeFileGivenText(fileName, gcodeText)
def analyzeFile(fileName): "Behold a gcode file." gcodeText = gcodec.getFileText(fileName) analyzeFileGivenText(fileName, gcodeText)
def extrudeFile( filename ): """Parse a gcode file and send the commands to the extruder. This function requires write access to the serial device, running as root is one way to get that access.""" print( 'File ' + filename + ' is being extruded.' ) fileText = gcodec.getFileText( filename ) gcodec.writeFileMessageSuffix( filename, extrudeText( fileText ), 'The gcode log file is saved as ', '_log' )