I am having a hard time getting a Zebra ZT230 to print a barcode label from a Project script. I am using a slight variation of a script from a earlier post.
I am getting this error: TypeError:'com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleModule' object is not callable I am calling this from the script console and also tried from a button event onActionPerformed with no luck.
I will admit I have never had experience setting up a printer, as well as getting a barcode to print form Ignition. Is there any articles that I should look into? Or is this still possible with the script I have with rework?
Let me know if I need to provide anymore information.
The Script Hint Scope just lets you chose what types of functions it will hint you for. For instance if you set it to Client, then you wont see functions that can only run in the gateway. It’s just a “Hint” to what you can use. It doesn’t play any role in what scope the script is actually executed in.
In perspective, all scripts run on the gateway. Scripts run in the script console are local to the machine / user running the designer.
Since both the script console and a designer session wont work in this context, would using the perspective workstation be a good way to test?
I also added in a loop as requested from support, which does seem to find the printer name as it loops, but once I get to the if foundService it doesn't seem to print. I am using the script console at the moment to be able to view the print statements.
After talking with support, we were able to get this script to print a serial number:
def printLabel(serialNum, printerName):
from javax.print import PrintService, PrintServiceLookup, DocFlavor, SimpleDoc
from java.lang import System
from org.python.core.util import StringUtil
from java.net import Socket
from java.io import DataOutputStream
foundService = False
printServices = PrintServiceLookup.lookupPrintServices(None, None)
for printService in printServices:
print("Made it in loop")
if printerName in printService.toString():
foundService = True
strMessage100 = '^XA'
strMessage112 = '^FT065,260,^BCN,N,N,N,N^FDS%s^FS' % serialNum
strMessage113 = '^FT170,170^A0N,40,45^FD%s^FS' % serialNum
strMessage199 = '^PQ1,0,1,Y^XZ'
strOut = strMessage100+strMessage112+strMessage113+strMessage199
job = printService.createPrintJob()
flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE
byteArray = StringUtil.toBytes(strOut)
doc = SimpleDoc(byteArray, flavor, None)
Although, I would like to print a barcode with this serial number. Is this possible with a bit of rewrite with this code, or would it be better suited to look into the reporting module to get my results?