General Category > Support Questions
AdvancedHMI not correct .NET framework for nugget.
paintman:
Is there a way to add AdvancedHMI to a project or does it have to be started using the blank project? Reason being, I am trying to add a Zebra nugget package to a project and keep getting these errors:
--- Quote --- CACHE https://api.nuget.org/v3/registration5-gz-semver2/zebra.printer.sdk/index.json
Resolved actions to install package 'Zebra.Printer.SDK.3.0.3271'
Install failed. Rolling back...
Package 'Zebra.Printer.SDK.3.0.3271' does not exist in project 'AdvancedHMI'
Package 'Zebra.Printer.SDK.3.0.3271' does not exist in folder 'C:\Users\ashquinn\Desktop\PrintTest\packages'
Executing nuget actions took 1.18 sec
Could not install package 'Zebra.Printer.SDK 3.0.3271'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Time Elapsed: 00:00:01.8759248
========== Finished ==========
--- End quote ---
I am not sure how to get around this, or if there is even a way to. I am trying to print a tag element from my PLC to a Zebra zt410/411 without using the PLC. I was opting for VB to be in control. Has anyone one worked on something similiar to this?
*Edited title to be more accurate*
Archie:
Several years ago I did a project that needed to print to a Zebra label printer. I installed the printer driver into Windows and set the zebra as the default printer. From there I send a raw string of data directly to the printer that was in the ZPL format.
Attached is a helper class I used for sending the data to the printer.
The code to send a string to the printer using the helper class:
--- Code: --- RawPrinterHelper.SendStringToPrinter(RawPrinterHelper.DefaultPrinterName(), s)
--- End code ---
I created a label using the Zebra software and saved it to be used as a template file. I then edited the label file to insert markers where I wanted to substitute data from the PLC. For example, [BatchNumber]
I wrote code to read that template, searched for the markers, then substituted the real data. And finally sending the string directly to the printer.
I can share more of the code, if you are interested
paintman:
I think I found a thread on plctalk refering to the project you mentioned. It said you used brackets [] as the container to look for in the zpl, but how did you get the bracket in to the file? Did you just prefill the text with [Variable] and then just replaced the inner string, or you just altered the actual zpl file?
I am very interested on seeing the code for this, I am not well versed on printer communications nor how I can link it to AHMI
Archie:
After creating the file using the Zebra designer software, I manually edited with Notepad. Attached is the file.
The first thing my code does is to read data from the PLC and put it in a local variable:
--- Code: --- Dim RecipeName As String = ""
Try
RecipeName = EthernetIPforCLXCom1.Read("Batch1RecipeName")
Catch ex As Exception
MsgBox("Failed to read Batch1RecipeName from PLC. " & ex.Message)
Exit Sub
End Try
--- End code ---
It then reads the file and stores it in a string:
--- Code: --- Dim s As String
Using sw As New System.IO.StreamReader("BatchTicketLabelFormat.prn")
s = sw.ReadToEnd()
End Using
--- End code ---
Using Regular Expression, the string is parsed looking for the brackets
--- Code: --- Dim x As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match(s, "\[(.*?)\]")
Dim Substitue As String
While Not String.IsNullOrEmpty(x.Value)
If x.Value.IndexOf("Batch1RecipeName") >= 0 Then
Substitue = RecipeName
Else
Substitue = "ZZZZZZ"
End If
s = s.Substring(0, x.Index) & Substitue & s.Substring(x.Index + x.Length)
x = System.Text.RegularExpressions.Regex.Match(s, "\[(.*?)\]")
End While
--- End code ---
And finally send the string directly to the printr:
--- Code: --- RawPrinterHelper.SendStringToPrinter(RawPrinterHelper.DefaultPrinterName(), s)
--- End code ---
paintman:
Okay that seems fairly simple. The rawprinterhelper is a tad confusing for me.
Is the rawprinterhelper just placed in a separate module and called when needed? I am looking at the class and trying to understand some segments of the code.
Would I just change this to what ever I name the ZPL file as, and the data type I assume would remain the same since its send a direct ZPL file?
--- Code: --- ' Set up the DOCINFO structure.
With di
.pDocName = "Mix Room Label Printer"
.pDataType = "RAW"
End With
--- End code ---
And as far as the printer name goes, I figure it wouldn't really matter as long as it is the default.
Navigation
[0] Message Index
[#] Next page
Go to full version