Beispiel #1
0
 def effect(self):
     # get hpgl data
     encoder = hpgl_encoder.hpglEncoder(self)
     try:
         self.options.to_port(self.options.to_language(encoder.getHpgl()))
     except hpgl_encoder.NoPathError:
         raise inkex.AbortExtension(
             _("No paths where found. Please convert objects to paths."))
Beispiel #2
0
 def effect(self):
     # get hpgl data
     myHpglEncoder = hpgl_encoder.hpglEncoder(self)
     try:
         self.hpgl = myHpglEncoder.getHpgl()
     except Exception as inst:
         if inst.args[0] == 'NO_PATHS':
             # issue error if no paths found
             inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths."))
             self.hpgl = ''
             return
         else:
             type, value, traceback = sys.exc_info()
             raise ValueError, ("", type, value), traceback
Beispiel #3
0
 def save(self, stream):
     self.options.debug = False
     # get hpgl data
     encoder = hpgl_encoder.hpglEncoder(self)
     try:
         hpgl = encoder.getHpgl()
     except hpgl_encoder.NoPathError:
         raise inkex.AbortExtension(
             _("No paths were found. Please convert objects you want into paths."))
     # convert raw HPGL to HPGL
     hpgl_init = 'IN'
    # if self.options.force > 0:
     #    hpgl_init += ';FS%d' % self.options.force
    # if self.options.speed > 0:
     #    hpgl_init += ';VS%d' % self.options.speed
     hpgl = hpgl_init + hpgl + ';SP0;PU0,0;IN; '
     stream.write(hpgl.encode('utf-8'))
Beispiel #4
0
 def effect(self):
     # get hpgl data
     myHpglEncoder = hpgl_encoder.hpglEncoder(self)
     try:
         self.hpgl, debugObject = myHpglEncoder.getHpgl()
     except Exception as inst:
         if inst.args[0] == 'NO_PATHS':
             # issue error if no paths found
             inkex.errormsg(
                 _("No paths where found. Please convert all objects you want to plot into paths."
                   ))
             return 1
         else:
             type, value, traceback = sys.exc_info()
             raise ValueError, ('', type, value), traceback
     # TODO: Get preview to work. This requires some work on the C++ side to be able to determine if it is
     # a preview or a final run. (Remember to set <effect needs-live-preview='false'> to true)
     '''
     if MAGIC:
         # reparse data for preview
         self.options.showMovements = True
         self.options.docWidth = self.uutounit(self.unittouu(self.document.getroot().get('width')), "px")
         self.options.docHeight = self.uutounit(self.unittouu(self.document.getroot().get('height')), "px")
         myHpglDecoder = hpgl_decoder.hpglDecoder(self.hpgl, self.options)
         doc, warnings = myHpglDecoder.getSvg()
         # deliver document to inkscape
         self.document = doc
     else:
     '''
     # convert to other formats
     if self.options.commandLanguage == 'HPGL':
         self.convertToHpgl()
     if self.options.commandLanguage == 'DMPL':
         self.convertToDmpl()
     if self.options.commandLanguage == 'KNK':
         self.convertToKNK()
     # output
     if self.options.debug:
         self.showDebugInfo(debugObject)
     elif self.options.portType == 'parallel':
         self.sendHpglToParallel()
     elif self.options.portType == 'serial':
         self.sendHpglToSerial()
Beispiel #5
0
 def effect(self):
     # get hpgl data
     myHpglEncoder = hpgl_encoder.hpglEncoder(self)
     try:
         self.hpgl, debugObject = myHpglEncoder.getHpgl()
     except Exception as inst:
         if inst.args[0] == 'NO_PATHS':
             # issue error if no paths found
             inkex.errormsg(_("No paths where found. Please convert all objects you want to plot into paths."))
             return 1
         else:
             type, value, traceback = sys.exc_info()
             raise ValueError, ('', type, value), traceback
     # TODO: Get preview to work. This requires some work on the C++ side to be able to determine if it is
     # a preview or a final run. (Remember to set <effect needs-live-preview='false'> to true)
     '''
     if MAGIC:
         # reparse data for preview
         self.options.showMovements = True
         self.options.docWidth = self.uutounit(self.unittouu(self.document.getroot().get('width')), "px")
         self.options.docHeight = self.uutounit(self.unittouu(self.document.getroot().get('height')), "px")
         myHpglDecoder = hpgl_decoder.hpglDecoder(self.hpgl, self.options)
         doc, warnings = myHpglDecoder.getSvg()
         # deliver document to inkscape
         self.document = doc
     else:
     '''
     # convert to other formats
     if self.options.commandLanguage == 'HPGL':
         self.convertToHpgl()
     if self.options.commandLanguage == 'DMPL':
         self.convertToDmpl()
     if self.options.commandLanguage == 'KNK':
         self.convertToKNK()
     # output
     if self.options.debug:
         self.showDebugInfo(debugObject)
     else:
         self.sendHpglToSerial()
Beispiel #6
0
 def effect(self):
     self.options.debug = False
     # get hpgl data
     myHpglEncoder = hpgl_encoder.hpglEncoder(self)
     try:
         self.hpgl, debugObject = myHpglEncoder.getHpgl()
     except Exception as inst:
         if inst.args[0] == 'NO_PATHS':
             # issue error if no paths found
             inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths."))
             self.hpgl = ''
             return
         else:
             type, value, traceback = sys.exc_info()
             raise ValueError, ("", type, value), traceback
     # convert raw HPGL to HPGL
     hpglInit = 'IN'
     if self.options.force > 0:
         hpglInit += ';FS%d' % self.options.force
     if self.options.speed > 0:
         hpglInit += ';VS%d' % self.options.speed
     self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; '
 def effect(self):
     self.options.debug = False
     # get hpgl data
     myHpglEncoder = hpgl_encoder.hpglEncoder(self)
     try:
         self.hpgl, debugObject = myHpglEncoder.getHpgl()
     except Exception as inst:
         if inst.args[0] == 'NO_PATHS':
             # issue error if no paths found
             inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths."))
             self.hpgl = ''
             return
         else:
             type, value, traceback = sys.exc_info()
             raise ValueError, ("", type, value), traceback
     # convert raw HPGL to HPGL
     hpglInit = 'IN'
     if self.options.force > 0:
         hpglInit += ';FS%d' % self.options.force
     if self.options.speed > 0:
         hpglInit += ';VS%d' % self.options.speed
     self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; '