## AutoLISP: Simple Numeric Array

Today’s featured routine is an example from a book about Visual Lisp Programming and was an example that we learned from as an example in class when I was in school.

It is a simple routine that lets you incrementally array a row of numbers. This might be helpful for creating numbered lists or placing numbers along a line…

Lee-Mac has made some pretty powerful numbering routines that can do a lot more than this routine does. These routines can be found here:

http://lee-mac.com/incrementalarray.html

http://lee-mac.com/numinc.html

Here’s how:

• NUMROW <enter>
• Specify the first text location – this will be # zero
• Specify the distance – either by picking 2 points on screen or by entering the distance in the command line
• Specify the angle – either by picking 2 points on screen or by entering the angle in the command line
• Specify the ending number of the array

~enjoy

```
; Example from book: Visual Lisp Programming
; NumRow.lsp by Cal Clater
;
; 1/12/xx
;
; Purpose: To create an evenly spaced row of incrementally increasing numbers,
; such as might be required for a chart or graph. The beginning number is zero
; and the last number is as specified.
;
(defun C:NumRow (/ PT1 DST DIR NN HN)
(setvar "CMDECHO" 0) (setvar "BLIPMODE" 0)
(princ "\nText will be center justified.")
(setq PT1 (getpoint "\nstart point of number row: ")
DST (getdist "\nDistance between number: ")
DIR (getorient "\nAngle: ")
NN 0
HN (getint "\nNumber sequence to be 0 through: ")
)
(command "TEXT" "C" PT1 "" "" "0")
(repeat HN
(setq PT1 (polar PT1 DIR DST))
(command "TEXT" "C" PT1 "" "" (itoa (setq NN (+ NN 1))))
)
)
```

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Creating, AutoLISP: Text, Uncategorized. Bookmark the permalink.

### 3 Responses to AutoLISP: Simple Numeric Array

some modifications to allow an increment, setting the initial number and height of the text

; Example from book: Visual Lisp Programming
; NumRow.lsp by Cal Clater
;
; 1/12/xx
;
; Purpose: To create an evenly spaced row of incrementally increasing numbers,
; such as might be required for a chart or graph. The beginning number is zero
; and the last number is as specified.
;
(defun C:NumRow (/ PT1 DST DIR NN HN INC TH)
(setvar “CMDECHO” 0) (setvar “BLIPMODE” 0)
(princ “\nText will be center justified.”)
(setq PT1 (getpoint “\nstart point of number row: “)
DST (getdist “\nDistance between number: “)
DIR (getorient “\nAngle: “)
NN (getint “\nStart number: “)
INC (getint “\nIncrement number: “)
HN (getint “\nFinish number: “)
HN (- HN 1)
TH (getreal “\nText height: “)
)
(command “TEXT” “C” PT1 TH “” (itoa NN ))
(repeat HN
(setq PT1 (polar PT1 DIR DST))
(command “TEXT” “C” PT1 “” “” (itoa (setq NN (+ NN INC))))
)
)

Cool – Thanks for the updated code
~Greg