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 ACAD Angle
  • Specify the ending number of the array

~enjoy

NumRow


; 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))))
    )
)
Advertisements

About AutoCAD Tips

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

  1. usercad says:

    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))))
    )
    )

  2. huaductiep says:

    Ask about custom Incremental Array
    ——————————————–
    Hello Experts ^^
    I was poor foreign language, so I’ll be brief
    Auto Lisp in Links http://lee-mac.com/incrementalarray.html
    How can you help me add custom increment increase
    Increments will be 2, 3 or more, not 1 as default
    Please mail me back in Lisp mail huaductiep3990hp@gmail.com
    Thank you very much experts!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s