def getFileOrGcodeDirectory( fileName, wasCancelled, words = [] ): "Get the gcode files in the directory the file is in if directory setting is true. Otherwise, return the file in a list." if isEmptyOrCancelled( fileName, wasCancelled ): return [] if isDirectorySetting(): return gcodec.getFilesWithFileTypeWithoutWords( 'gcode', words, fileName ) return [ fileName ]
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 writeHypertext(): "Run pydoc, then read, write and delete each of the files." shellCommand = 'pydoc -w ./' commandResult = os.system( shellCommand ) if commandResult != 0: print( 'Failed to execute the following command in writeHypertext in docwrap.' ) print( shellCommand ) hypertextFiles = gcodec.getFilesWithFileTypeWithoutWords( 'html' ) if len( hypertextFiles ) <= 0: print( 'Failed to find any help files in writeHypertext in docwrap.' ) return documentDirectoryPath = gcodec.getAbsoluteFolderPath( hypertextFiles[ 0 ], 'documentation' ) removeFilesInDirectory( documentDirectoryPath ) sortedReplaceFiles = [] for hypertextFile in hypertextFiles: sortedReplaceFiles.append( hypertextFile.replace( '.html', '. html' ) ) sortedReplaceFiles.sort() hypertextFiles = [] for sortedReplaceFile in sortedReplaceFiles: hypertextFiles.append( sortedReplaceFile.replace( '. html', '.html' ) ) transferredFileNames = [] for hypertextFileIndex in xrange( len( hypertextFiles ) ): readWriteDeleteHypertextHelp( documentDirectoryPath, hypertextFileIndex, hypertextFiles, transferredFileNames ) for transferredFileNameIndex in xrange( len( transferredFileNames ) ): readWriteNavigationHelp( documentDirectoryPath, transferredFileNameIndex, transferredFileNames ) writeContentsFile( documentDirectoryPath, transferredFileNames ) print( '%s files were wrapped.' % len( transferredFileNames ) )
def getFileOrGcodeDirectory( fileName, wasCancelled, words = [] ): "Get the gcode files in the directory the file is in if directory preference is true. Otherwise, return the file in a list." if isEmptyOrCancelled( fileName, wasCancelled ): return [] if isDirectoryPreference(): return gcodec.getFilesWithFileTypeWithoutWords( 'gcode', words, fileName ) return [ fileName ]
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 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 slc file." if fileName == '': unmodified = gcodec.getFilesWithFileTypeWithoutWords( 'slc' ) if len( unmodified ) == 0: print( "There is no slc file in this folder." ) return None fileName = unmodified[ 0 ] carving = SLCCarving() carving.readFile( 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 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 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 writeHypertext(): "Run pydoc, then read, write and delete each of the files." shellCommand = 'pydoc -w ./' commandResult = os.system( shellCommand ) if commandResult != 0: print( 'Failed to execute the following command in writeHypertext in docwrap.' ) print( shellCommand ) hypertextFiles = gcodec.getFilesWithFileTypeWithoutWords( 'html' ) if len( hypertextFiles ) <= 0: print( 'Failed to find any help files in writeHypertext in docwrap.' ) return documentDirectoryPath = gcodec.getAbsoluteFolderPath( hypertextFiles[ 0 ], 'documentation' ) removeFilesInDirectory( documentDirectoryPath ) # for hypertextFile in hypertextFiles[ : 1 ]: for hypertextFile in hypertextFiles: readWriteDeleteHypertextHelp( documentDirectoryPath, hypertextFile ) print( '%s files were wrapped.' % len( hypertextFiles ) )
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 getGCodeFilesWhichAreNotLogFiles(): "Get gcode files which are not log files." return gcodec.getFilesWithFileTypeWithoutWords('gcode', ['_log'] )
def getGCodeFilesWhichAreNotLogFiles(): "Get gcode files which are not log files." return gcodec.getFilesWithFileTypeWithoutWords( 'gcode', [ '_log' ] )