本文整理汇总了Python中fabmetheus_utilities.svg_reader.SVGReader类的典型用法代码示例。如果您正苦于以下问题:Python SVGReader类的具体用法?Python SVGReader怎么用?Python SVGReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SVGReader类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCraftedGcode
def getCraftedGcode(self, fileName, repository, svgText):
"Parse svgText and store the scale svgText."
svgReader = SVGReader()
svgReader.parseSVG('', svgText)
if svgReader.sliceDictionary == None:
print('Warning, nothing will be done because the sliceDictionary could not be found getCraftedGcode in preface.')
return ''
xyPlaneScale = repository.xyPlaneScale.value
zAxisScale = repository.zAxisScale.value
decimalPlacesCarried = int(svgReader.sliceDictionary['decimalPlacesCarried'])
layerHeight = zAxisScale * float(svgReader.sliceDictionary['layerHeight'])
edgeWidth = float(svgReader.sliceDictionary['edgeWidth'])
loopLayers = svgReader.loopLayers
for loopLayer in loopLayers:
setLoopLayerScale(loopLayer, xyPlaneScale, zAxisScale)
cornerMaximum = Vector3(-912345678.0, -912345678.0, -912345678.0)
cornerMinimum = Vector3(912345678.0, 912345678.0, 912345678.0)
svg_writer.setSVGCarvingCorners(cornerMaximum, cornerMinimum, layerHeight, loopLayers)
svgWriter = svg_writer.SVGWriter(
True,
cornerMaximum,
cornerMinimum,
decimalPlacesCarried,
layerHeight,
edgeWidth)
commentElement = svg_writer.getCommentElement(svgReader.documentElement)
procedureNameString = svgReader.sliceDictionary['procedureName'] + ',scale'
return svgWriter.getReplacedSVGTemplate(fileName, loopLayers, procedureNameString, commentElement)
示例2: getCraftedGcode
def getCraftedGcode(self, fileName, repository, svgText):
"Parse svgText and store the bottom svgText."
svgReader = SVGReader()
svgReader.parseSVG("", svgText)
if svgReader.sliceDictionary == None:
print(
"Warning, nothing will be done because the sliceDictionary could not be found getCraftedGcode in preface."
)
return ""
decimalPlacesCarried = int(svgReader.sliceDictionary["decimalPlacesCarried"])
edgeWidth = float(svgReader.sliceDictionary["edgeWidth"])
layerHeight = float(svgReader.sliceDictionary["layerHeight"])
loopLayers = svgReader.loopLayers
zMinimum = 987654321.0
for loopLayer in loopLayers:
zMinimum = min(loopLayer.z, zMinimum)
deltaZ = (
repository.altitude.value + repository.additionalHeightOverLayerThickness.value * layerHeight - zMinimum
)
for loopLayer in loopLayers:
loopLayer.z += deltaZ
cornerMaximum = Vector3(-912345678.0, -912345678.0, -912345678.0)
cornerMinimum = Vector3(912345678.0, 912345678.0, 912345678.0)
svg_writer.setSVGCarvingCorners(cornerMaximum, cornerMinimum, layerHeight, loopLayers)
svgWriter = svg_writer.SVGWriter(
True, cornerMaximum, cornerMinimum, decimalPlacesCarried, layerHeight, edgeWidth
)
commentElement = svg_writer.getCommentElement(svgReader.documentElement)
procedureNameString = svgReader.sliceDictionary["procedureName"] + ",bottom"
return svgWriter.getReplacedSVGTemplate(fileName, loopLayers, procedureNameString, commentElement)
示例3: getCraftedGcode
def getCraftedGcode(self, fileName, repository, svgText):
"Parse svgText and store the bottom svgText."
svgReader = SVGReader()
svgReader.parseSVG('', svgText)
if svgReader.sliceDictionary == None:
print('Warning, nothing will be done because the sliceDictionary could not be found getCraftedGcode in preface.')
return ''
decimalPlacesCarried = int(svgReader.sliceDictionary['decimalPlacesCarried'])
layerThickness = float(svgReader.sliceDictionary['layerThickness'])
perimeterWidth = float(svgReader.sliceDictionary['perimeterWidth'])
rotatedLoopLayers = svgReader.rotatedLoopLayers
zMinimum = 987654321.0
for rotatedLoopLayer in rotatedLoopLayers:
zMinimum = min(rotatedLoopLayer.z, zMinimum)
deltaZ = repository.altitude.value + repository.additionalHeightOverLayerThickness.value * layerThickness - zMinimum
for rotatedLoopLayer in rotatedLoopLayers:
rotatedLoopLayer.z += deltaZ
cornerMaximum = Vector3(-912345678.0, -912345678.0, -912345678.0)
cornerMinimum = Vector3(912345678.0, 912345678.0, 912345678.0)
svg_writer.setSVGCarvingCorners(cornerMaximum, cornerMinimum, layerThickness, rotatedLoopLayers)
svgWriter = svg_writer.SVGWriter(
True,
cornerMaximum,
cornerMinimum,
decimalPlacesCarried,
layerThickness,
perimeterWidth)
commentElement = svg_writer.getCommentElement(svgReader.root)
procedureNameString = svgReader.sliceDictionary['procedureName'] + ',bottom'
return svgWriter.getReplacedSVGTemplate(fileName, procedureNameString, rotatedLoopLayers, commentElement)
示例4: __init__
def __init__(self):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.extruderActive = False
self.lineIndex = 0
self.oldLocation = None
self.svgReader = SVGReader()
self.doingLayerN = 0
示例5: __init__
def __init__(self):
'Add empty lists.'
self.layerHeight = 1.0
self.maximumZ = - 987654321.0
self.minimumZ = 987654321.0
self.svgReader = SVGReader()
示例6: __init__
def __init__(self):
"Add empty lists."
self.layerThickness = 1.0
self.maximumZ = - 999999999.0
self.minimumZ = 999999999.0
self.svgReader = SVGReader()
示例7: PrefaceSkein
class PrefaceSkein(object):
"A class to preface a skein of extrusions."
def __init__(self):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.extruderActive = False
self.lineIndex = 0
self.oldLocation = None
self.svgReader = SVGReader()
def addInitializationToOutput(self):
"Add initialization gcode to the output."
self.distanceFeedRate.addTagBracketedLine('format', 'skeinforge gcode')
absoluteFilePathUntilDot = archive.getUntilDot(archive.getCraftPluginsDirectoryPath('preface.py'))
dateTodayString = date.today().isoformat().replace('-', '.')[2 :]
if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script on Enrique's computer?
archive.writeFileText(archive.getVersionFileName(), dateTodayString)
versionText = archive.getFileText(archive.getVersionFileName())
self.distanceFeedRate.addTagBracketedLine('version', versionText)
dateTimeTuple = datetime.now().timetuple()
created = dateTodayString + '|%s:%s' % (dateTimeTuple[3], dateTimeTuple[4])
self.distanceFeedRate.addTagBracketedLine('created', created)
self.distanceFeedRate.addLine('(<extruderInitialization>)')
if self.repository.setPositioningToAbsolute.value:
self.distanceFeedRate.addLine('G90 ;set positioning to absolute') # Set positioning to absolute.
if self.repository.setUnitsToMillimeters.value:
self.distanceFeedRate.addLine('G21 ;set units to millimeters') # Set units to millimeters.
if self.repository.startAtHome.value:
self.distanceFeedRate.addLine('G28 ;start at home') # Start at home.
if self.repository.turnExtruderOffAtStartUp.value:
self.distanceFeedRate.addLine('M103') # Turn extruder off.
craftTypeName = skeinforge_profile.getCraftTypeName()
self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName)
self.distanceFeedRate.addTagBracketedLine('decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried)
layerHeight = float(self.svgReader.sliceDictionary['layerHeight'])
self.distanceFeedRate.addTagRoundedLine('layerThickness', layerHeight)
self.distanceFeedRate.addTagRoundedLine('layerHeight', layerHeight)
if self.repository.meta.value:
self.distanceFeedRate.addTagBracketedLine('meta', self.repository.meta.value)
edgeWidth = float(self.svgReader.sliceDictionary['edgeWidth'])
self.distanceFeedRate.addTagRoundedLine('edgeWidth', edgeWidth)
self.distanceFeedRate.addTagRoundedLine('perimeterWidth', edgeWidth)
self.distanceFeedRate.addTagBracketedLine('profileName', skeinforge_profile.getProfileName(craftTypeName))
self.distanceFeedRate.addLine('(<settings>)')
pluginFileNames = skeinforge_craft.getPluginFileNames()
for pluginFileName in pluginFileNames:
self.addToolSettingLines(pluginFileName)
self.distanceFeedRate.addLine('(</settings>)')
self.distanceFeedRate.addTagBracketedLine('timeStampPreface', strftime('%Y%m%d_%H%M%S'))
procedureNames = self.svgReader.sliceDictionary['procedureName'].replace(',', ' ').split()
for procedureName in procedureNames:
self.distanceFeedRate.addTagBracketedProcedure(procedureName)
self.distanceFeedRate.addTagBracketedProcedure('preface')
self.distanceFeedRate.addLine('(</extruderInitialization>)') # Initialization is finished, extrusion is starting.
self.distanceFeedRate.addLine('(<crafting>)') # Initialization is finished, crafting is starting.
def addPreface( self, loopLayer ):
"Add preface to the carve layer."
self.distanceFeedRate.addLine('(<layer> %s )' % loopLayer.z ) # Indicate that a new layer is starting.
for loop in loopLayer.loops:
self.distanceFeedRate.addGcodeFromLoop(loop, loopLayer.z)
self.distanceFeedRate.addLine('(</layer>)')
def addShutdownToOutput(self):
"Add shutdown gcode to the output."
self.distanceFeedRate.addLine('(</crafting>)') # GCode formatted comment
if self.repository.turnExtruderOffAtShutDown.value:
self.distanceFeedRate.addLine('M103') # Turn extruder motor off.
def addToolSettingLines(self, pluginName):
"Add tool setting lines."
preferences = skeinforge_craft.getCraftPreferences(pluginName)
if skeinforge_craft.getCraftValue('Activate %s' % pluginName.capitalize(), preferences) != True:
return
for preference in preferences:
valueWithoutReturn = str(preference.value).replace('\n', ' ').replace('\r', ' ')
if preference.name != 'WindowPosition' and not preference.name.startswith('Open File'):
line = '%s %s %s' % (pluginName, preference.name.replace(' ', '_'), valueWithoutReturn)
self.distanceFeedRate.addTagBracketedLine('setting', line)
def getCraftedGcode( self, repository, gcodeText ):
"Parse gcode text and store the bevel gcode."
self.repository = repository
self.svgReader.parseSVG('', gcodeText)
if self.svgReader.sliceDictionary == None:
print('Warning, nothing will be done because the sliceDictionary could not be found getCraftedGcode in preface.')
return ''
self.distanceFeedRate.decimalPlacesCarried = int(self.svgReader.sliceDictionary['decimalPlacesCarried'])
self.addInitializationToOutput()
for loopLayerIndex, loopLayer in enumerate(self.svgReader.loopLayers):
settings.printProgressByNumber(loopLayerIndex, len(self.svgReader.loopLayers), 'preface')
self.addPreface( loopLayer )
self.addShutdownToOutput()
return self.distanceFeedRate.output.getvalue()
示例8: __init__
def __init__(self):
"""Add empty lists."""
self.extrusionHeight = 1.0
self.maximumZ = - 987654321.0
self.minimumZ = 987654321.0
self.svgReader = SVGReader()
示例9: __init__
class PrefaceSkein:
"A class to preface a skein of extrusions."
def __init__(self):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.extruderActive = False
self.lineIndex = 0
self.oldLocation = None
self.svgReader = SVGReader()
def addFromUpperLowerFile( self, fileName ):
"Add lines of text from the fileName or the lowercase fileName, if there is no file by the original fileName in the directory."
fileText = settings.getFileInAlterationsOrGivenDirectory( os.path.dirname( __file__ ), fileName )
fileLines = archive.getTextLines(fileText)
self.distanceFeedRate.addLinesSetAbsoluteDistanceMode( fileLines )
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('creation', 'skeinforge') # GCode formatted comment
absoluteFilePathUntilDot = os.path.abspath( __file__ )[ : os.path.abspath( __file__ ).rfind('.') ]
if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script on Enrique's computer?
archive.writeFileText( archive.getVersionFileName(), date.today().isoformat().replace('-', '.')[ 2 : ] )
versionText = archive.getFileText( archive.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 = skeinforge_profile.getCraftTypeName()
self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName )
self.distanceFeedRate.addTagBracketedLine('decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried )
layerThickness = float( self.svgReader.sliceDictionary['layerThickness'] )
self.distanceFeedRate.addTagBracketedLine('layerThickness', self.distanceFeedRate.getRounded( layerThickness ) )
if self.prefaceRepository.meta.value:
self.distanceFeedRate.addTagBracketedLine('meta', self.prefaceRepository.meta.value )
perimeterWidth = float( self.svgReader.sliceDictionary['perimeterWidth'] )
self.distanceFeedRate.addTagBracketedLine('perimeterWidth', self.distanceFeedRate.getRounded( perimeterWidth ) )
self.distanceFeedRate.addTagBracketedLine('profileName', skeinforge_profile.getProfileName( craftTypeName ) )
self.distanceFeedRate.addTagBracketedLine('procedureDone', self.svgReader.sliceDictionary['procedureDone'] )
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 addPreface( self, rotatedBoundaryLayer ):
"Add preface to the carve layer."
self.distanceFeedRate.addLine('(<layer> %s )' % rotatedBoundaryLayer.z ) # Indicate that a new layer is starting.
if rotatedBoundaryLayer.rotation != None:
self.distanceFeedRate.addTagBracketedLine('bridgeRotation', str( rotatedBoundaryLayer.rotation ) ) # Indicate the bridge rotation.
for loop in rotatedBoundaryLayer.loops:
self.distanceFeedRate.addGcodeFromLoop( loop, rotatedBoundaryLayer.z )
self.distanceFeedRate.addLine('(</layer>)')
def addShutdownToOutput(self):
"Add shutdown gcode to the output."
self.distanceFeedRate.addLine('(</extrusion>)') # GCode formatted comment
if self.prefaceRepository.turnExtruderOffAtShutDown.value:
self.distanceFeedRate.addLine('M103') # Turn extruder motor off.
self.addFromUpperLowerFile( self.prefaceRepository.nameOfEndFile.value ) # Add an end file if it exists.
def getCraftedGcode( self, prefaceRepository, gcodeText ):
"Parse gcode text and store the bevel gcode."
self.prefaceRepository = prefaceRepository
self.svgReader.parseSVG('', gcodeText )
self.distanceFeedRate.decimalPlacesCarried = int( self.svgReader.sliceDictionary['decimalPlacesCarried'] )
self.addInitializationToOutput()
for rotatedBoundaryLayerIndex, rotatedBoundaryLayer in enumerate(self.svgReader.rotatedLoopLayers):
settings.printProgressByNumber(rotatedBoundaryLayerIndex, len(self.svgReader.rotatedLoopLayers), 'preface')
self.addPreface( rotatedBoundaryLayer )
self.addShutdownToOutput()
return self.distanceFeedRate.output.getvalue()
示例10: __init__
class SVGCarving:
"An svg carving."
def __init__( self ):
"Add empty lists."
self.layerThickness = 1.0
self.maximumZ = - 999999999.0
self.minimumZ = 999999999.0
self.svgReader = SVGReader()
def __repr__( self ):
"Get the string representation of this carving."
return self.getCarvedSVG()
def addXML( self, depth, output ):
"Add xml for this object."
xml_simple_writer.addXMLFromObjects( depth, self.svgReader.rotatedLoopLayers, output )
def getCarveCornerMaximum( self ):
"Get the corner maximum of the vertices."
return self.cornerMaximum
def getCarveCornerMinimum( self ):
"Get the corner minimum of the vertices."
return self.cornerMinimum
def getCarvedSVG( self ):
"Get the carved svg text."
if len( self.svgReader.rotatedLoopLayers ) < 1:
return ''
decimalPlacesCarried = max(0, 2 - int(math.floor(math.log10(self.layerThickness))))
self.svgWriter = svg_writer.SVGWriter(True, self, decimalPlacesCarried)
return self.svgWriter.getReplacedSVGTemplate(self.fileName, 'basic', self.svgReader.rotatedLoopLayers)
def getCarveLayerThickness( self ):
"Get the layer thickness."
return self.layerThickness
def getCarveRotatedBoundaryLayers( self ):
"Get the rotated boundary layers."
return self.svgReader.rotatedLoopLayers
def getInterpretationSuffix( self ):
"Return the suffix for a carving."
return 'svg'
def parseInitialization( self ):
"Parse gcode initialization and store the parameters."
if self.svgReader.sliceDictionary == None:
return
self.layerThickness = euclidean.getFloatDefaultByDictionary( self.layerThickness, self.svgReader.sliceDictionary, 'layerThickness')
self.maximumZ = euclidean.getFloatDefaultByDictionary( self.maximumZ, self.svgReader.sliceDictionary, 'maxZ')
self.minimumZ = euclidean.getFloatDefaultByDictionary( self.minimumZ, self.svgReader.sliceDictionary, 'minZ')
def parseSVG( self, fileName, svgText ):
"Parse SVG text and store the layers."
if svgText == '':
return
self.svgReader.parseSVG( fileName, svgText )
self.parseInitialization()
self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, self.maximumZ )
self.cornerMinimum = Vector3( 999999999.0, 999999999.0, self.minimumZ )
for rotatedBoundaryLayer in self.svgReader.rotatedLoopLayers:
for loop in rotatedBoundaryLayer.loops:
for point in loop:
pointVector3 = Vector3( point.real, point.imag, rotatedBoundaryLayer.z )
self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3 )
self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3 )
def setCarveBridgeLayerThickness( self, bridgeLayerThickness ):
"Set the bridge layer thickness. If the infill is not in the direction of the bridge, the bridge layer thickness should be given as None or not set at all."
pass
def setCarveLayerThickness( self, layerThickness ):
"Set the layer thickness."
self.layerThickness = layerThickness
def setCarveImportRadius( self, importRadius ):
"Set the import radius."
pass
def setCarveIsCorrectMesh( self, isCorrectMesh ):
"Set the is correct mesh flag."
pass
示例11: __init__
class PrefaceSkein:
"A class to preface a skein of extrusions."
def __init__(self):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.extruderActive = False
self.lineIndex = 0
self.oldLocation = None
self.svgReader = SVGReader()
def addFromUpperLowerFile(self, fileName):
"Add lines of text from the fileName or the lowercase fileName, if there is no file by the original fileName in the directory."
self.distanceFeedRate.addLinesSetAbsoluteDistanceMode(settings.getLinesInAlterationsOrGivenDirectory(fileName))
def addInitializationToOutput(self):
"Add initialization gcode to the output."
self.addFromUpperLowerFile(self.repository.nameOfStartFile.value) # Add a start file if it exists.
self.distanceFeedRate.addTagBracketedLine('creation', 'skeinforge') # GCode formatted comment
# absoluteFilePathUntilDot = os.path.abspath(__file__)[: os.path.abspath(__file__).rfind('.')]
# if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script on Enrique's computer?
# archive.writeFileText(archive.getVersionFileName(), date.today().isoformat().replace('-', '.')[2 :])
versionText = archive.getFileText(archive.getVersionFileName())
self.distanceFeedRate.addTagBracketedLine('version', versionText) # GCode formatted comment
self.distanceFeedRate.addLine('(<extruderInitialization>)') # GCode formatted comment
if self.repository.setPositioningToAbsolute.value:
self.distanceFeedRate.addLine('G90 ;set positioning to absolute') # Set positioning to absolute.
if self.repository.setUnitsToMillimeters.value:
self.distanceFeedRate.addLine('G21 ;set units to millimeters') # Set units to millimeters.
if self.repository.startAtHome.value:
self.distanceFeedRate.addLine('G28 ;start at home') # Start at home.
if self.repository.resetExtruder.value:
self.distanceFeedRate.addLine('G92 E0 ;reset extruder distance') # Start at home.
# if self.repository.turnExtruderOffAtStartUp.value:
# self.distanceFeedRate.addLine('M103') # Turn extruder off.
craftTypeName = skeinforge_profile.getCraftTypeName()
self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName)
self.distanceFeedRate.addTagBracketedLine('decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried)
layerThickness = float(self.svgReader.sliceDictionary['layerThickness'])
self.distanceFeedRate.addTagRoundedLine('layerThickness', layerThickness)
if self.repository.meta.value:
self.distanceFeedRate.addTagBracketedLine('meta', self.repository.meta.value)
if self.repository.extraLineOne.value:
self.distanceFeedRate.addLine( self.repository.extraLineOne.value)
if self.repository.extraLineTwo.value:
self.distanceFeedRate.addLine( self.repository.extraLineTwo.value)
if self.repository.extraLineThree.value:
self.distanceFeedRate.addLine( self.repository.extraLineThree.value)
if self.repository.extraLineFour.value:
self.distanceFeedRate.addLine( self.repository.extraLineFour.value)
if self.repository.extraLineFive.value:
self.distanceFeedRate.addLine( self.repository.extraLineFive.value)
perimeterWidth = float(self.svgReader.sliceDictionary['perimeterWidth'])
self.distanceFeedRate.addTagRoundedLine('perimeterWidth', perimeterWidth)
self.distanceFeedRate.addTagBracketedLine('profileName', skeinforge_profile.getProfileName(craftTypeName))
self.distanceFeedRate.addLine('(<settings>)')
pluginFileNames = skeinforge_craft.getPluginFileNames()
for pluginFileName in pluginFileNames:
self.addToolSettingLines(pluginFileName)
self.distanceFeedRate.addLine('(</settings>)')
self.distanceFeedRate.addTagBracketedLine('timeStampPreface', strftime('%Y%m%d_%H%M%S'))
procedureNames = self.svgReader.sliceDictionary['procedureName'].replace(',', ' ').split()
for procedureName in procedureNames:
self.distanceFeedRate.addTagBracketedLine('procedureName', procedureName)
self.distanceFeedRate.addTagBracketedLine('procedureName', 'preface')
self.distanceFeedRate.addLine('(</extruderInitialization>)') # Initialization is finished, extrusion is starting.
self.distanceFeedRate.addLine('(<crafting>)') # Initialization is finished, crafting is starting.
def addPreface( self, rotatedLoopLayer ):
"Add preface to the carve layer."
self.distanceFeedRate.addLine('(<layer> %s )' % rotatedLoopLayer.z ) # Indicate that a new layer is starting.
if rotatedLoopLayer.rotation != None:
self.distanceFeedRate.addTagBracketedLine('bridgeRotation', str( rotatedLoopLayer.rotation ) ) # Indicate the bridge rotation.
for loop in rotatedLoopLayer.loops:
self.distanceFeedRate.addGcodeFromLoop(loop, rotatedLoopLayer.z)
self.distanceFeedRate.addLine('(</layer>)')
def addShutdownToOutput(self):
"Add shutdown gcode to the output."
self.distanceFeedRate.addLine('(</crafting>)') # GCode formatted comment
# if self.repository.turnExtruderOffAtShutDown.value:
# self.distanceFeedRate.addLine('M103') # Turn extruder motor off.
self.addFromUpperLowerFile(self.repository.nameOfEndFile.value) # Add an end file if it exists.
def addToolSettingLines(self, toolName):
"Add tool setting lines."
craftModule = skeinforge_craft.getCraftModule(toolName)
preferences = settings.getReadRepository(craftModule.getNewRepository()).preferences
for preference in preferences:
if preference.name.startswith('Activate %s' % toolName.capitalize()):
if preference.value == False:
return
for preference in preferences:
valueWithoutReturn = str(preference.value).replace('\n', ' ').replace('\r', ' ')
if preference.name != 'WindowPosition' and not preference.name.startswith('Open File'):
line = '%s %s %s' % (toolName, preference.name.replace(' ', '_'), valueWithoutReturn)
self.distanceFeedRate.addTagBracketedLine('setting', line)
def getCraftedGcode( self, repository, gcodeText ):
"Parse gcode text and store the bevel gcode."
self.repository = repository
self.svgReader.parseSVG('', gcodeText)
#.........这里部分代码省略.........
示例12: __init__
class PrefaceSkein:
"A class to preface a skein of extrusions."
def __init__(self):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.extruderActive = False
self.lineIndex = 0
self.oldLocation = None
self.svgReader = SVGReader()
def addInitializationToOutput(self):
"Add initialization gcode to the output."
self.distanceFeedRate.addTagBracketedLine("format", "skeinforge gcode")
absoluteFilePathUntilDot = archive.getUntilDot(archive.getCraftPluginsDirectoryPath("preface.py"))
dateTodayString = date.today().isoformat().replace("-", ".")[2:]
if (
absoluteFilePathUntilDot
== "/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface"
): # is this script on Enrique's computer?
archive.writeFileText(archive.getVersionFileName(), dateTodayString)
versionText = archive.getFileText(archive.getVersionFileName())
self.distanceFeedRate.addTagBracketedLine("version", versionText)
dateTimeTuple = datetime.now().timetuple()
created = dateTodayString + "|%s:%s" % (dateTimeTuple[3], dateTimeTuple[4])
self.distanceFeedRate.addTagBracketedLine("created", created)
self.distanceFeedRate.addLine("(<extruderInitialization>)")
if self.repository.setPositioningToAbsolute.value:
self.distanceFeedRate.addLine("G90 ;set positioning to absolute") # Set positioning to absolute.
if self.repository.setUnitsToMillimeters.value:
self.distanceFeedRate.addLine("G21 ;set units to millimeters") # Set units to millimeters.
if self.repository.startAtHome.value:
self.distanceFeedRate.addLine("G28 ;start at home") # Start at home.
if self.repository.turnExtruderOffAtStartUp.value:
self.distanceFeedRate.addLine("M103") # Turn extruder off.
craftTypeName = skeinforge_profile.getCraftTypeName()
self.distanceFeedRate.addTagBracketedLine("craftTypeName", craftTypeName)
self.distanceFeedRate.addTagBracketedLine("decimalPlacesCarried", self.distanceFeedRate.decimalPlacesCarried)
layerHeight = float(self.svgReader.sliceDictionary["layerHeight"])
self.distanceFeedRate.addTagRoundedLine("layerThickness", layerHeight)
self.distanceFeedRate.addTagRoundedLine("layerHeight", layerHeight)
if self.repository.meta.value:
self.distanceFeedRate.addTagBracketedLine("meta", self.repository.meta.value)
edgeWidth = float(self.svgReader.sliceDictionary["edgeWidth"])
self.distanceFeedRate.addTagRoundedLine("edgeWidth", edgeWidth)
self.distanceFeedRate.addTagRoundedLine("perimeterWidth", edgeWidth)
self.distanceFeedRate.addTagBracketedLine("profileName", skeinforge_profile.getProfileName(craftTypeName))
self.distanceFeedRate.addLine("(<settings>)")
pluginFileNames = skeinforge_craft.getPluginFileNames()
for pluginFileName in pluginFileNames:
self.addToolSettingLines(pluginFileName)
self.distanceFeedRate.addLine("(</settings>)")
self.distanceFeedRate.addTagBracketedLine("timeStampPreface", strftime("%Y%m%d_%H%M%S"))
procedureNames = self.svgReader.sliceDictionary["procedureName"].replace(",", " ").split()
for procedureName in procedureNames:
self.distanceFeedRate.addTagBracketedProcedure(procedureName)
self.distanceFeedRate.addTagBracketedProcedure("preface")
self.distanceFeedRate.addLine(
"(</extruderInitialization>)"
) # Initialization is finished, extrusion is starting.
self.distanceFeedRate.addLine("(<crafting>)") # Initialization is finished, crafting is starting.
def addPreface(self, loopLayer):
"Add preface to the carve layer."
self.distanceFeedRate.addLine("(<layer> %s )" % loopLayer.z) # Indicate that a new layer is starting.
for loop in loopLayer.loops:
self.distanceFeedRate.addGcodeFromLoop(loop, loopLayer.z)
self.distanceFeedRate.addLine("(</layer>)")
def addShutdownToOutput(self):
"Add shutdown gcode to the output."
self.distanceFeedRate.addLine("(</crafting>)") # GCode formatted comment
if self.repository.turnExtruderOffAtShutDown.value:
self.distanceFeedRate.addLine("M103") # Turn extruder motor off.
def addToolSettingLines(self, pluginName):
"Add tool setting lines."
preferences = skeinforge_craft.getCraftPreferences(pluginName)
if skeinforge_craft.getCraftValue("Activate %s" % pluginName.capitalize(), preferences) != True:
return
for preference in preferences:
valueWithoutReturn = str(preference.value).replace("\n", " ").replace("\r", " ")
if preference.name != "WindowPosition" and not preference.name.startswith("Open File"):
line = "%s %s %s" % (pluginName, preference.name.replace(" ", "_"), valueWithoutReturn)
self.distanceFeedRate.addTagBracketedLine("setting", line)
def getCraftedGcode(self, repository, gcodeText):
"Parse gcode text and store the bevel gcode."
self.repository = repository
self.svgReader.parseSVG("", gcodeText)
if self.svgReader.sliceDictionary == None:
print(
"Warning, nothing will be done because the sliceDictionary could not be found getCraftedGcode in preface."
)
return ""
self.distanceFeedRate.decimalPlacesCarried = int(self.svgReader.sliceDictionary["decimalPlacesCarried"])
self.addInitializationToOutput()
for loopLayerIndex, loopLayer in enumerate(self.svgReader.loopLayers):
settings.printProgressByNumber(loopLayerIndex, len(self.svgReader.loopLayers), "preface")
self.addPreface(loopLayer)
self.addShutdownToOutput()
#.........这里部分代码省略.........
示例13: __init__
class PrefaceSkein:
"""A class to preface a skein of extrusions."""
def __init__(self):
self.distanceFeedRate = gcodec.DistanceFeedRate()
self.extruderActive = False
self.lineIndex = 0
self.oldLocation = None
self.svgReader = SVGReader()
def addFromUpperLowerFile(self, fileName):
"""Add lines of text from the fileName or the lowercase fileName, if there is no file by the original fileName in the directory."""
self.distanceFeedRate.addLinesSetAbsoluteDistanceMode(settings.getLinesInAlterationsOrGivenDirectory(fileName))
def addInitializationToOutput(self):
"""Add initialization gcode to the output."""
self.addFromUpperLowerFile(self.repository.nameOfStartFile.value) # Add a start file if it exists.
self.distanceFeedRate.addTagBracketedLine('creation', 'skeinforge') # GCode formatted comment
absoluteFilePathUntilDot = os.path.abspath(__file__)[: os.path.abspath(__file__).rfind('.')]
if absoluteFilePathUntilDot == '/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/skeinforge_application/skeinforge_plugins/craft_plugins/preface': #is this script on Enrique's computer?
archive.writeFileText(archive.getVersionFileName(), date.today().isoformat().replace('-', '.')[2 :])
versionText = archive.getFileText(archive.getVersionFileName())
self.distanceFeedRate.addTagBracketedLine('version', versionText) # GCode formatted comment
self.distanceFeedRate.addLine('(<extruderInitialization>)') # GCode formatted comment
if self.repository.setPositioningToAbsolute.value:
self.distanceFeedRate.addLine('G90 ;set positioning to absolute') # Set positioning to absolute.
if self.repository.setUnitsToMillimeters.value:
self.distanceFeedRate.addLine('G21 ;set units to millimeters') # Set units to millimeters.
if self.repository.startAtHome.value:
self.distanceFeedRate.addLine('G28 ;start at home') # Start at home.
if self.repository.resetExtruder.value:
self.distanceFeedRate.addLine('G92 E0 ;reset extruder distance') # Start at home.
craftTypeName = skeinforge_profile.getCraftTypeName()
self.distanceFeedRate.addTagBracketedLine('craftTypeName', craftTypeName)
self.distanceFeedRate.addTagBracketedLine('decimalPlacesCarried', self.distanceFeedRate.decimalPlacesCarried)
extrusionHeight = float(self.svgReader.sliceDictionary['extrusionHeight'])
self.distanceFeedRate.addTagRoundedLine('extrusionHeight', extrusionHeight)
if self.repository.meta.value:
self.distanceFeedRate.addTagBracketedLine('meta', self.repository.meta.value)
extrusionWidth = float(self.svgReader.sliceDictionary['extrusionWidth'])
self.distanceFeedRate.addTagRoundedLine('extrusionWidth', extrusionWidth)
self.distanceFeedRate.addTagBracketedLine('profileName', skeinforge_profile.getProfileName(craftTypeName))
procedureNames = self.svgReader.sliceDictionary['procedureName'].replace(',', ' ').split()
for procedureName in procedureNames:
self.distanceFeedRate.addTagBracketedLine('procedureName', procedureName)
self.distanceFeedRate.addTagBracketedLine('procedureName', 'preface')
self.distanceFeedRate.addLine('(</extruderInitialization>)') # Initialization is finished, extrusion is starting.
self.distanceFeedRate.addLine('(<crafting>)') # Initialization is finished, crafting is starting.
def addPreface( self, rotatedLoopLayer ):
"""Add preface to the carve layer."""
self.distanceFeedRate.addLine('(<layer> %s )' % rotatedLoopLayer.z ) # Indicate that a new layer is starting.
if rotatedLoopLayer.rotation is not None:
self.distanceFeedRate.addTagBracketedLine('bridgeRotation', str( rotatedLoopLayer.rotation ) ) # Indicate the bridge rotation.
for loop in rotatedLoopLayer.loops:
self.distanceFeedRate.addGcodeFromLoop(loop, rotatedLoopLayer.z)
self.distanceFeedRate.addLine('(</layer>)')
def addShutdownToOutput(self):
"Add shutdown gcode to the output."
self.distanceFeedRate.addLine('(</crafting>)') # GCode formatted comment
self.addFromUpperLowerFile(self.repository.nameOfEndFile.value) # Add an end file if it exists.
def getCraftedGcode( self, repository, gcodeText ):
"""Parse gcode text and store the bevel gcode."""
self.repository = repository
self.svgReader.parseSVG('', gcodeText)
if self.svgReader.sliceDictionary is None:
print('Warning, nothing will be done because the sliceDictionary could not be found getCraftedGcode in preface.')
return ''
self.distanceFeedRate.decimalPlacesCarried = int(self.svgReader.sliceDictionary['decimalPlacesCarried'])
self.addInitializationToOutput()
for rotatedLoopLayerIndex, rotatedLoopLayer in enumerate(self.svgReader.rotatedLoopLayers):
settings.printProgressByNumber(rotatedLoopLayerIndex, len(self.svgReader.rotatedLoopLayers), 'preface')
self.addPreface( rotatedLoopLayer )
self.addShutdownToOutput()
return self.distanceFeedRate.output.getvalue()