barcode 128

Has anyone added barcode 128 to a part or assembly file property variable? We would like to use this data down stream on a drawing.

We have managed to introduce the macro code to create a barcode 128 item that does display on our drawing sheet, but we are looking for other ideas and want to hear what other have done.

SolidworksApi macros
Answers 11
RB
RB 2018-05-04 Best Answer

Yup I did it....See one example

comment imagecomment image
KC
KC 2018-05-04

Hello,

A barcode note in general, not just in SW:

We implemented bar coding for a particular client's products and found that you just can't "print" a bar code font.

There's actually some encoding going to make the data actually be scanned.

So test print and test scan.

Just typin',

Kevin

GW
GW 2018-05-04

That looks nice, however, I am not planning to display the 128 barcode on part or assembly. I want it available inside our PDM database

GW
GW 2018-05-04

We can print Barcode 39 or 3of9 as this character set is just 39 characters. Numbers and capital letters only, no special characters.

Barcode 128 is a full character set that includes compression to reduce the physical length of the bar code strip.

This compression requires coding, a macro, and a means to trigger the execution.

RB
RB 2018-05-05

It's just a font you must comply with the international STD for 128Code Bar only. And at the data level as in Excell you should concatenate data to be shown in the registry and replace it with the source you need.

Have you tried yet?

IK
IK 2018-05-06

do you use some kind of barcode font?

Barcode Font - Completely Free Download of code 3 of 9 and 128 Barcode Fonts

<p></p><p></p><p>Public Function code128$(propertyValue$)</p><p>    Dim i%, checksum&, mini%, dummy%, tableB As Boolean</p><p>    code128$ = ""</p><p>    If Len(propertyValue$) > 0 Then</p><p>        For i% = 1 To Len(propertyValue$)</p><p>            Select Case Asc(Mid$(propertyValue$, i%, 1))</p><p>                Case 32 To 126, 203</p><p>                Case Else</p><p>                    i% = 0</p><p>                    Exit For</p><p>            End Select</p><p>        Next</p><p>        code128$ = ""</p><p>        tableB = True</p><p>        If i% > 0 Then</p><p>            i% = 1</p><p>            Do While i% <= Len(propertyValue$)</p><p>                If tableB Then</p><p>                    mini% = IIf(i% = 1 Or i% + 3 = Len(propertyValue$), 4, 6)</p><p>                    GoSub testnum</p><p>                    If mini% < 0 Then</p><p>                        If i% = 1 Then</p><p>                            code128$ = Chr$(210)</p><p>                        Else</p><p>                            code128$ = code128$ & Chr$(204)</p><p>                        End If</p><p>                        tableB = False</p><p>                    Else</p><p>                        If i% = 1 Then code128$ = Chr$(209)</p><p>                    End If</p><p>                End If</p><p>                If Not tableB Then</p><p>                    mini% = 2</p><p>                    GoSub testnum</p><p>                    If mini% < 0 Then</p><p>                        dummy% = Val(Mid$(propertyValue$, i%, 2))</p><p>                        dummy% = IIf(dummy% < 95, dummy% + 32, dummy% + 105)</p><p>                        code128$ = code128$ & Chr$(dummy%)</p><p>                        i% = i% + 2</p><p>                    Else</p><p>                        code128$ = code128$ & Chr$(205)</p><p>                        tableB = True</p><p>                    End If</p><p>                End If</p><p>                If tableB Then</p><p>                    code128$ = code128$ & Mid$(propertyValue$, i%, 1)</p><p>                    i% = i% + 1</p><p>                End If</p><p>            Loop</p><p>            For i% = 1 To Len(code128$)</p><p>                dummy% = Asc(Mid$(code128$, i%, 1))</p><p>                dummy% = IIf(dummy% < 127, dummy% - 32, dummy% - 105)</p><p>                If i% = 1 Then checksum& = dummy%</p><p>                checksum& = (checksum& + (i% - 1) * dummy%) Mod 103</p><p>            Next</p><p>            checksum& = IIf(checksum& < 95, checksum& + 32, checksum& + 105)</p><p>            code128$ = code128$ & Chr$(checksum&) & Chr$(211)</p><p>        End If</p><p>    End If</p><p>    Exit Function</p><p>testnum:</p><p>  </p><p>    mini% = mini% - 1</p><p>    If i% + mini% <= Len(propertyValue$) Then</p><p>        Do While mini% >= 0</p><p>            If Asc(Mid$(propertyValue$, i% + mini%, 1)) < 48 Or Asc(Mid$(propertyValue$, i% + mini%, 1)) > 57 Then Exit Do</p><p>            mini% = mini% - 1</p><p>        Loop</p><p>    End If</p><p>    Return</p><p>End Function</p>
GW
GW 2018-05-07

Yes we do use a barcode font. It is called "Bars and Spaces"

We got this font file from a programmer that is helping us place the codes on our drawings.

A macro is used to process some of this work and a macro requires a trigger. A rebuild command is one way to trigger the macro.

Not a huge deal, but a user can make a drawing, save and close without doing a rebuild. so the barcodes display out of date data.

So, I would like to move the macro upstream to the part and assembly file (templates) so this barcode is available earlier for other purposes(Not sure what shop floor automation those purposes are yet) and to be more confidant that the macro has run to display current data.

Again, We have this working pretty much as we need it. I am looking for other ideas and methods that have been used by others.

Thanks for reading

comment imagecomment imagecomment imagecomment image
RB
RB 2018-05-07

Why you use a macro?

a requiriment of Ford is

  1. 1. The barcode (itself) is to be printed on a white background
  2. 2. The barcode symbology is to be code 39 or code 128.
  3. 3. The barcode must not to contain any special characters, spaces or dashes.  The content

Of the barcode can eliminate the ford base number and use the model and suffix. Ab39 19b548 aa

Needs to be written in full format but on the barcode the format can be ab39 aa to increase

The spacing between the barcode lines to allow easier reading

  1. 4. Quiet zones are required before the start and at the end of the barcode; quiet zones are

The area immediately preceding the start character and following the stop character that

Contains no markings. The size of each quiet zone is to be a minimum of ten times the narrowest

Bar in the barcode.

  1. 5. The barcode label material is to be low sheen or non-gloss and have a permanent adhesive backing.
  2. 6. The label must not be able to be smudged when handled with dry hands or gloves.

Only change font Arial by 128 barcode

Save as template and that's all

comment imagecomment imagecomment imagecomment imagecomment imagecomment image
GW
GW 2018-05-07

We are using a macro to process the compression within barcode 128

We are using Barcode 128 to keep the spaces and special characters in our part description.

Our end customer dictates descriptions to be "NOUN, MODIFIER; ATTRIBUTE, ATTRIBUTE"

PS
PS 2018-11-20

i have two questions regarding this macro. how do you implement it? i.e. i want to make a template where, a field of text is manually generated to code39, but without having to instal a .ttf file on every computer, which can end up using this template?

is there a code39 version of this`?

RR
RR 2024-02-03

' ******************************************************************************
' C:\Users\Rrodriguez\AppData\Local\Temp\swx28756\Macro1.swb - macro recorded on 02/02/24 by rrodriguez
' ******************************************************************************

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim CodeBString As String
Dim i As Integer
Dim MyFile As String
Dim TalliedTotal As Integer
Dim AdjTotal As Variant
Dim AdjDec As Variant
Dim BCode As String

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

MyFile = "19-18-0009-2"  'Left(swModel.GetTitle, InStr(swModel.GetTitle, " ") - 1)
MsgBox MyFile & ", LENGTH = " & Len(MyFile)

CodeBString = "Â!""#$%&'()*=,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÃÄÅÆÇÈÉÊËÌÍÎ"

TalliedTotal = 0
AdjTotal = 0

For i = 1 To Len(MyFile)
    MsgBox "PART NUMBER = " & MyFile & Chr(10) & Chr(10) & _
        "Character in position" & i & " is """ & Mid(MyFile, i, 1) & Chr(34) & Chr(10) & _
        "Corresponding Code Value for this character is " & InStr(CodeBString, Mid(MyFile, i, 1)) - 1 & Chr(10) & Chr(10) & _
        "The running total is as follows: " & Chr(10) & i & " x " & InStr(CodeBString, Mid(MyFile, i, 1)) - 1 & " = " & _
        i * (InStr(CodeBString, Mid(MyFile, i, 1)) - 1) & _
        "      (" & i * (InStr(CodeBString, Mid(MyFile, i, 1)) - 1) & " + " & TalliedTotal & " = " & i * (InStr(CodeBString, Mid(MyFile, i, 1)) - 1) + TalliedTotal & ")"
        TalliedTotal = i * (InStr(CodeBString, Mid(MyFile, i, 1)) - 1) + TalliedTotal
Next i

AdjTotal = (104 + TalliedTotal) / 103
AdjDec = AdjTotal - Int(AdjTotal)

MsgBox "To find the Code128 CHECK CHARACTER, add 104 to the running total " & Tallietotal & " and divide by 103.  " & _
        "Grab the decimal portion of this number and multiply 103 (i.e. remainder).  This will give you the ""LOOK-UP"" value for the CHECK CHARACTER." & Chr(10) & Chr(10) & _
        "So....... " & Chr(10) & Chr(10) & "( 104 + " & TalliedTotal & " ) / 103 = " & AdjTotal & Chr(10) & AdjDec & _
        " x 103 = " & AdjDec * 103 & Chr(10) & Chr(10) & "This is your look-up reference number, " & _
        AdjDec * 103 & ", which will allow you to find the corresponding barcode CHECK CHARACTER." & Chr(10) & _
        "In our case, " & AdjDec * 103 & " corresponds to """ & _
        Mid(CodeBString, AdjDec * 103 + 1, 1) & Chr(34)

        
MsgBox "Your barcode ""code"" will consist of the START character ""Ì"" or key stroke ALT+0204, the part number (MyFile), the check character, " & _
        "and the STOP character ""Î"" or key stroke ALT+0206." & Chr(10) & Chr(10) & "So your barcode code will appear as follows:  Î" & MyFile & _
        Mid(CodeBString, AdjDec * 103 + 1, 1) & "Î" & Chr(10) & Chr(10) & _
        "Convert the font of this string to code128 and you should be good to go." & Chr(10) & Chr(10) & _
        "Information obtained from website" & Chr(10) & "www.barcodefaq.com/1d/code-128/"
        
        
' ******************************************************************************
' Code without all the garbage above is as follows:
' ******************************************************************************

 

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

 

MyFile = "19-18-0009-2"  'Left(swModel.GetTitle, InStr(swModel.GetTitle, " ") - 1)
MsgBox MyFile & ", LENGTH = " & Len(MyFile)

 

CodeBString = "Â!""#$%&'()*=,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÃÄÅÆÇÈÉÊËÌÍÎ"

 

TalliedTotal = 0
AdjTotal = 0

 

For i = 1 To Len(MyFile)
        TalliedTotal = i * (InStr(CodeBString, Mid(MyFile, i, 1)) - 1) + TalliedTotal
Next i

 

AdjTotal = (104 + TalliedTotal) / 103
AdjDec = AdjTotal - Int(AdjTotal)

 

BCode = "Ì" & MyFile & Mid(CodeBString, AdjDec * 103 + 1, 1) & "Î"
MsgBox "BARCODE = " & BCode

 

End Sub

 

 

 

For CODE39 your START/STOP character is the asterisk "*" and I believe that barcode font is already part of the microsoft.package.

​​​​​​​