AutoLISP: Array Single Line (Vector)

So the new array tool is cool but it may be frustrating at the same time. Autodesk didn’t make the new array tool very intuitive. Here is a lisp routine that works in any UCS and is more intuitive than the new array tool. I have used this one while working in 3D so I do know that it works just fine in 3D. Thanks again to Lee-Mac

This array tool works in one direction (as seen below)

Here’s how:

  • ARRV <enter> to start (Array Vector)
  • Select object(s) to be arrayed <enter>
  • Specify the base point
  • Specify the spacing
  • Move the cursor in the direction for the array and click to place the array.

(defun c:arrv ( / ss->list copyv dx gr nl nx obs obx p0 pd pw px vx ) (vl-load-com)

;; © Lee Mac 2011 found at the swamp

(defun ss->list ( ss / i l )

(if ss

(repeat (setq i (sslength ss))

(setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))




(defun copyv ( ob n v / i b l ) (setq i 1 b (vlax-3D-point '(0. 0. 0.)))

(repeat n

(foreach obj ob

(vla-move (car (setq l (cons (vla-copy obj) l))) b (vlax-3D-point (mapcar '* v (list i i i))))


(setq i (1+ i))






(setq obs (ss->list (ssget '((0 . "~VIEWPORT")))))

(setq p0 (getpoint "\nBase Point: "))

(setq px (getpoint "\nArray Vector: " p0))

(setq pw (trans p0 1 0)

pd (trans p0 1 3)

vx (trans (mapcar '- px p0) 1 0) dx (distance '(0. 0. 0.) vx)


(not (equal dx 0.0 1e-14))

(princ "\nArray Endpoint: ")


(while (= 5 (car (setq gr (grread 't 13 0)))) (redraw)

(setq obx (car (mapcar 'vla-delete obx))

nx (fix (setq nl (/ (caddr (trans (setq gr (mapcar '- (cadr gr) p0)) 1 vx)) dx)))

obx (copyv obs (abs nx) (mapcar (if (minusp nx) '- '+) vx))


(grvecs (list -3 '(0. 0. 0.) (mapcar '* (trans vx 0 3) (list nl nl nl)))


(list 1. 0. 0. (car pd))

(list 0. 1. 0. (cadr pd))

(list 0. 0. 1. (caddr pd))

(list 0. 0. 0. 1.)





(redraw) (princ)


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, Modifying, New in 2012, TIPS. Bookmark the permalink.

Leave a Reply

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

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

Facebook photo

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

Connecting to %s