Well I played with this long enough. I actually have work to do this morning
****NOT FULLY TESTED***
;;; ------------------------------------------------------------------------
;;; BARCODE.LSP
;;;
;;; Copyright © October, 2009
;;; Timothy G. Spangler
;;;
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and
;;; that both that copyright notice and the limited warranty and
;;; restricted rights notice below appear in all supporting
;;; documentation.
;;;
;;; Description:
;;; Creates a barcode from a piece of text
;;; ------------------------------------------------------------------------
(defun C:BARCODE (/ BarCodeText BarCodeList BarList TextLength Counter Char Bar OldLunits)
;; Set units to decimal
(setq OldLunits (getvar "LUNITS"))
(setvar "LUNITS" 2)
;; Get string to barcode
(if (= "" (setq BarCodeText (getstring "\n Enter text to barcode:<TEST>")))
(setq BarCodeText "TEST")
)
;; Set the barcode list 128B
(setq BarCodeList
(list
(cons "" 212222 )(cons "!" 222122)(cons "\"" 222221)(cons "#" 121223)
(cons "$" 121322)(cons "%" 131222)(cons "&" 122213)(cons "\'" 122312)
(cons "\(" 132212)(cons "\)" 221213)(cons "*" 221312)(cons "\+" 231212)
(cons "\," 112232)(cons "\-" 122132)(cons "\." 122231)(cons "\/" 113222)
(cons "0" 123122)(cons "1" 123221)(cons "2" 223211)(cons "3" 221132)
(cons "4" 221231)(cons "5" 213212)(cons "6" 223112)(cons "7" 312131)
(cons "8" 311222)(cons "9" 321122)(cons "\:" 321221)(cons "\;" 312212)
(cons "\<" 322112)(cons "\=" 322211)(cons "\>" 212123)(cons "\?" 212321)
(cons "@" 232121)(cons "A" 111323)(cons "B" 131123)(cons "C" 131321)
(cons "D" 112313)(cons "E" 132113)(cons "F" 132311)(cons "G" 211313)
(cons "H" 231113)(cons "I" 231311)(cons "J" 112133)(cons "K" 112331)
(cons "L" 132131)(cons "M" 113123)(cons "N" 113321)(cons "O" 133121)
(cons "P" 313121)(cons "Q" 211331)(cons "R" 231131)(cons "S" 213113)
(cons "T" 213311)(cons "U" 213131)(cons "V" 311123)(cons "W" 311321)
(cons "X" 331121)(cons "Y" 312113)(cons "Z" 312311)(cons "[" 332111)
(cons "\\" 314111)(cons "\]" 221411)(cons "^" 431111)(cons "_" 111224)
(cons "`" 111422)(cons "a" 121124)(cons "b" 121421)(cons "c" 141122)
(cons "d" 141221)(cons "e" 112214)(cons "f" 112412)(cons "g" 122114)
(cons "h" 122411)(cons "i" 142112)(cons "j" 142211)(cons "k" 241211)
(cons "l" 221114)(cons "m" 413111)(cons "n" 241112)(cons "o" 134111)
(cons "p" 111242)(cons "q" 121142)(cons "r" 121241)(cons "s" 114212)
(cons "t" 124112)(cons "u" 124211)(cons "v" 411212)(cons "w" 421112)
(cons "x" 421211)(cons "y" 212141)(cons "z" 214121)(cons "{" 412121)
(cons "|" 111143)(cons "}" 111341)(cons "~" 131141)
)
)
;; Start Barcode
(setq BarList (cons 211214 BarList))
;; Start Counter
(setq Counter 1)
;; Step throught text and create barcode list from it
(repeat (strlen BarCodeText)
(setq Char (substr BarCodeText Counter 1))
(setq Bar (cdr(assoc Char BarCodeList)))
(setq BarList (cons Bar BarList))
(setq Counter (1+ Counter))
)
;; End Barcode
(setq BarList (cons 2331112 BarList))
;; Reverse bar list
(setq BarList (reverse BarList))
;; Draw Bar
(DRAW_BAR BarList)
;; Reet units
(setvar "LUNITS" OldLunits)
;; Echo to the command line
(princ (strcat "\n Bar Code create for \"" BarCodeText "\""))
;; Quiet exit
(princ)
)
(defun DRAW_BAR (BarList / StartPoint BarPoint Counter BarCodeGroup Loop DrawBar BarChr )
;; Define start pont for barcode
(setq StartPoint (getpoint "\n Define starting point for barcode:"))
;; Start Counter
(setq Counter 0)
;; Step through barlist and draw barcodes
(repeat (length BarList)
;; Convert number to string
(setq BarCodeGroup (rtos (nth Counter BarList)2 0))
;; Start loop counter
(setq Loop 1)
;; Start with a bar
(setq DrawBar T)
;; Step through the bar code group
(repeat (strlen BarCodeGroup)
;; Break the bargroup down into bars
(setq BarChr (substr BarCodeGroup Loop 1))
;; Set the first point of charater
(setq BarPoint (polar StartPoint 0.0 (* 0.5 (atoi BarChr))))
(setq StartPoint (polar StartPoint 0.0 (atoi BarChr)))
;; Draw Bar
(if DrawBar
(progn
;; Draw the pline
(BAR_PLINE (list BarPoint (polar BarPoint (/ pi 2.0) 60.0)) (atoi BarChr))
;; Turn off draw bar
(setq DrawBar nil)
)
;; Turn on draw bar
(setq DrawBar T)
)
;; Add to the loop
(setq Loop (1+ Loop))
)
;; Add to the counter
(setq Counter (1+ Counter))
)
)
;; Draw pline for bar code
(defun BAR_PLINE (PointList Width / Group10List PolyLineList)
(setq PolyLineList
(list
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 6 "Continuous")
(cons 8 "0")
(cons 43 Width)
(cons 90 (length PointList))
(cons 70 0)
)
)
(setq Group10List (mapcar '(lambda (Coord) (cons 10 Coord)) PointList))
(setq PolyLineList (append PolyLineList Group10List))
(entmakex PolyLineList)
)
;;;
;;; Echos to the command line
(princ "\nBarCode v1.0© \n Timothy Spangler, \n October, 2009....loaded.")
(print)
;;; End echo
*** Fixed Protected symbol error