EAN 13 generator ilogic?

EAN 13 generator ilogic?

Anonymous
Not applicable
658 Views
4 Replies
Message 1 of 5

EAN 13 generator ilogic?

Anonymous
Not applicable

I'm wondering if there is a way to generate EAN 13 in drawing with ilogic? Here: http://grandzebu.net/informatique/codbar-en/ean13.htm I found a VB code with a font to download, can someone help me to create a ilogic with using the EAN13 font?

0 Likes
Accepted solutions (1)
659 Views
4 Replies
Replies (4)
Message 2 of 5

JamieVJohnson2
Collaborator
Collaborator

Very interesting.  I'm on it.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 5

JamieVJohnson2
Collaborator
Collaborator
Accepted solution
Sub Main
	Dim strBarcode As String = String.Empty
	Dim invApp As Inventor.Application = ThisApplication
	Dim invDoc As Inventor.Document = invApp.ActiveDocument
	Dim txtBox As Inventor.TextBox = Nothing
	If invDoc IsNot Nothing Then
		If invDoc.SelectSet.Count > 0 Then
			For Each ent As Object In invDoc.SelectSet
				If TypeOf ent Is TextBox Then
					txtBox = ent
					strBarcode = txtBox.text
					Dim strEAN13 As String = ean13(strBarcode)
					If strEAN13 <> String.Empty Then
						txtBox.FormattedText =  "<StyleOverride Font='Code EAN13' FontSize='1' Bold='False' Underline='False'>" & strEAN13 & "</StyleOverride>"
					End If
				End If
			Next
		End If
	End If
End Sub

Public Function ean13(chain As String)
	'This function is governed by the GNU Lesser General Public License (GNU LGPL)
	'V 1.1.1
	'Parameters : a 12 digits length string
	'Return : * a string which give the bar code when it is dispayed with EAN13.TTF font
	'         * an empty string if the supplied parameter is no good
	Dim tableA As Boolean
	Dim checksum As Integer
	Dim first As Integer
	Dim BarCode As String = String.Empty
	Dim i As Integer 
	'Check for 12 characters
	If Len(chain) = 12 Then
		'And they are really digits
		For i = 1 To 12
			If Asc(Mid(chain, i, 1)) < 48 Or Asc(Mid(chain, i, 1)) > 57 Then
				i = 0
				Exit For
			End If
		Next
		If i = 13 Then
			'Calculation of the checksum
			For i = 12 To 1 Step -2
				checksum = checksum + Val(Mid(chain, i, 1))
			Next
			checksum = checksum * 3
			For i = 11 To 1 Step -2
				checksum = checksum + Val(Mid(chain, i, 1))
			Next
			chain = chain & (10 - checksum Mod 10) Mod 10
			'The first digit is taken just as it is, the second one come from table A
			BarCode = Left(chain, 1) & Chr(65 + Val(Mid(chain, 2, 1)))
			first = Val(Left(chain, 1))
			For i = 3 To 7
				tableA = False
				Select Case i
					Case 3
						Select Case first
							Case 0 To 3
							tableA = True
						End Select
					Case 4
						Select Case first
							Case 0, 4, 7, 8
								tableA = True
						End Select
					Case 5
						Select Case first
							Case 0, 1, 4, 5, 9
								tableA = True
						End Select
					Case 6
						Select Case first
							Case 0, 2, 5, 6, 7
								tableA = True
						End Select
					Case 7
						Select Case first
							Case 0, 3, 6, 8, 9
								tableA = True
						End Select
				End Select
				If tableA Then
					BarCode = BarCode & Chr(65 + Val(Mid(chain, i, 1)))
				Else
					BarCode = BarCode & Chr(75 + Val(Mid(chain, i, 1)))
				End If
			Next
			BarCode = BarCode & "*"   'Add middle separator
			For i = 8 To 13
				BarCode = BarCode & Chr(97 + Val(Mid(chain, i, 1)))
			Next
			BarCode = BarCode & "+"   'Add end mark
		End If
	End If
	Return BarCode
End Function

How to use: Make a text box, place into it the value to be converted such as 012345678901, then select the text box while not in text edit mode (one or many), then run the rule.

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
Message 4 of 5

Anonymous
Not applicable

It's not working.

 

You could do it like that:

1. create a temporary variable iproperty and place into it the value to convert
2. set trigger to call the rule when changing the temporary iproperty
3. the text box with a temporary variable, written in EAN13

When I change the iproperty, the text field changes by ilogic converting code.

 

For example, like here: https://www.youtube.com/watch?v=1CoqCDdEBCw

 

Thanks in advance.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Can anyone help me?

0 Likes