Tblin AutoLisp Modes

(defun c:tblin (/)

;Initialize counters.
(setq Row 0)
(setq Col 0)
;Change these variables to adjust row and columns.
(setq OffCol 2)
(setq OffRow 0.2)

(setq ColMax 9)
(setq eof 0)

(setq Filename (FileToRead))
(setq FileHandler (open Filename “r”))

(while (= eof 0)
(progn
(while (< Col (* OffCol ColMax)) (progn (setq TextIn (read-line FileHandler)) (if (= TextIn “~”) (setq eof 1) ;Else (progn (setq Col (+ Col OffCol)) (command “TEXT” (list Col Row 0.0) “0.08” “0” TextIn) );End progn );End if );End progn );wend (setq Row (- Row OffRow)) (setq Col 0) );End progn );Wend (close FileHandler) (princ) ) (defun FileToRead (/) ; Prompt for file to be inserted (if (= 1 (getvar “FILEDIA”)) (setq FileToRead (getfiled “File to Read” “” “TXT” 12)) ;Else (progn (\n princ “Set variable FILEDIA to 1 then try again.”) (setq FileToRead nil) );End progn );End if ) ;;; Save modes ;;; (defun MODES (a) (setq MLST ‘()) (repeat (length a) (setq MLST (append MLST (list (list (car a) (getvar (car a)))))) (setq a (cdr a)) ) ;;; Restore modes ;;; (defun MODER () (repeat (length MLST) (setvar (caar MLST) (cadar MLST)) (setq MLST (cdr MLST)) ) ) ;;; Ascii Text error handler ;;; (defun at_err (st) ; If an error (such as CTRL-C) occurs ; while this command is active… (if (and (/= st “Function cancelled”) (/= st “quit / exit abort”) ) (princ (strcat “\nError: ” st)) ) (moder) ; Restore modified modes (if (= (type rtfile) ‘FILE) (close rtfile) ) (setq rtfile nil) (setq *error* olderr) ; Restore old *error* handler (princ) ) (defun asctxt (/) (setq olderr *error* *error* at_err) (modes ‘(“BLIPMODE” “CMDECHO” “HIGHLIGHT”)) ; Prompt for file to be inserted (while (null rtfile) (if (null at_fnm) (if (= 1 (getvar “FILEDIA”)) (setq rf (getfiled “File to Read” “” “” 12)) (progn (initget 1) (princ “\nFile to read (including extension): “) (setq rf (getstring)) ) ) (if (= 1 (getvar “FILEDIA”)) (setq rf (getfiled “File to Read” at_fnm “” 12)) (progn (princ “\nFile to read (including extension)/<“) (princ (strcat at_fnm “>: “))
(setq rf (getstring))
)
)
)
(if (= rf nil) (exit))
(if (= rf 1)
(if (null at_fnm)
(progn
(initget 1)
(princ “\nFile to read (including extension): “)
(setq rf (getstring))
)
(progn
(princ “\nFile to read (including extension)/<“) (princ (strcat at_fnm “>: “))
(setq rf (getstring))
)
)
)
(if (and (= rf “”) (/= nil at_fnm))
(setq rf at_fnm)
)
(setq rfa (findfile rf))
(if (= “~” rf)
(progn
(setq rfa nil)
(setq rtfile nil)
)
)
(if rfa
(progn
(setq at_fnm rfa)
(if (null (setq rtfile (open rfa “r”)))
(princ (strcat
“\n\tFile found, but couldn’t open ” at_fnm ” for reading. “))
)
)
(if (/= “~” rf)
(if (and (< 4 (strlen rf)) (/= (substr rf (- (strlen rf) 3) 1) “.”) ) (princ “\nFile not found. Extension may be missing.”) (princ “\nFile not found. “) ) ) ) ) (setq cont T) (if (= “Yes” (getkword “\nSet up columns? : “))
(progn
(setq opt (append opt ‘(16)))
(initget (+ 1 2))
(setq cd (getdist pt “\nDistance between columns: “))
(initget (+ 1 2 4))
(setq nl (getint “\nNumber of lines per column: “))
)
)
)
)
(setvar “BLIPMODE” 0)
(setvar “HIGHLIGHT” 0)
(setvar “CMDECHO” 0)
(setq eof nil)
(setq s (repeat l1
(read-line rtfile)
))
(setq lc (1+ lc))
(1ltxt)
(while (null eof)
(if (= d “Auto”)
(progn
(setq s (read-line rtfile))
(setq lc (1+ lc))
(if s
(progn
(if (= lc (1+ nl))
(1ltxt)
(progn
(if (member ‘1 opt)
(setq s (strcat “%%u” s “%%u”))
)
(if (member ‘2 opt)
(setq s (strcat “%%o” s “%%o”))
)
(if (member ‘4 opt)
(setq s (strcase s))
)
(if (member ‘8 opt)
(setq s (strcase s T))
)
(command “_.TEXT” “” s)
(setq c (1+ c))
(if (= c n)
(setq eof T)
)
)
)
)
(setq eof T)
)
)
(progn
(setq s (read-line rtfile))
(setq lc (1+ lc))
(if s
(1ltxt)
(setq eof T)
)
)
)
)
(close rtfile)
(setq rtfile nil)
(moder) ; Restore modified modes
(setq *error* olderr) ; Restore old *error* handler
(princ)
)

;(defun c:at () (asctxt))
(defun c:asctext () (asctxt))
(princ “\n ASCTEXT loaded.”)
(princ)

(defun C:TBLIN ()

;;Select file using a dialog box.
(setq RpFileName
(getfiled “Select file to incorporate” “/acad/support/” “txt” 8)
)
;;Open the file.
(setq FileNum (open RpFileName “r”))

;;Test for an empty file.
(setq LineFile (read-line FileNum))

;;Getting data to Autocad.
(while (/= LineFile nil)
(setq LineFile (read-line FileNum)
(princ LineFile)
)
)
)

Similar Posts

  • Training Tracking 101 . Allena Software

    Founder and developer of Training Tracking 101. A software company that creates affordable, easy to learn and implement database desktop solutions. As an entrepreneur I; research, designed, wrote programming code and performed testing and debugging of applications using programming languages and technologies. Designed and created graphics and content for software products, support, website and marketing…

  • TrainingTracking101

    The Importance of Training Tracking in Modern Organizations In today’s fast-paced business environment, continuous learning and development are crucial for maintaining a competitive edge. Training tracking systems have become an essential tool for organizations aiming to ensure their workforce remains skilled and compliant with industry standards. This article explores the significance of training tracking and…

  • vsnap lisp

    (DEFUN C:VSNAP (/) ; Sept. 25,97. By V.Mendez ; This function centers an object between two parallel lines. (SETVAR “CMDECHO” 0) (SETQ SelObj (ENTSEL “\nSelect Object : “)) (SETQ BPoint (GETPOINT “\nBase Point : “)) (COMMAND “OSNAP” “NONE”) (COMMAND “OSNAP” “NEA”) (SETQ Point1 (GETPOINT “\nFirst Point [nearest] : “)) (COMMAND “OSNAP” “PER”) (SETQ Point2 (GETPOINT…

  • Plocky Lisp

    (Defun FC (Func N Xo dx) ( (Setq LP ‘()) (Setq Int (/ dx N) (Setq x (-Xo Int)) (Repeat (+ N 1) (Setq x (+x Int)) (Setq y (FuncA x)) (Setq LPP (List x y)) (Setq LP (Cons LPP LP)) ) ) ) (Defun FuncA (V) (* V V) ) (Defun DrawF (ListP) (Setq…

  • FLC Simulation

    A computer simulation application that applies statistical mechanics to predict pre-synthesis of Liquid Crystal properties from chemical structure is needed. As well as the creation of calculation, videoand data manipulation tools and a user interface. read more …