How to use new array command with lisp

How to use new array command with lisp

lemanhhung0302
Contributor Contributor
3,603 Views
6 Replies
Message 1 of 7

How to use new array command with lisp

lemanhhung0302
Contributor
Contributor

Array in AutoCAD 2012 and later seems to be more difficult than oder one.

In this video, I 'll show you:

  •     How to use Older Array command - ARRAYCLASSIC in new AutoCAD.
  •     How to use ARRAY command
  •     Special, a mini lisp AR command will help you more.

 

Have fun!

 

Download link: AR.VLX from Mediafire

www.tankhanh.com.vn
3,604 Views
6 Replies
Replies (6)
Message 2 of 7

lemanhhung0302
Contributor
Contributor

Source code:

(defun c:ar ( / ss p1 p2 therows thecols drows dcols)
	(vl-load-com)
	(setq ss (ssget "_:L"))
	(setq p1 (getpoint " Specify first point: "))
	(setq p2 (getpoint p1 " Specify second point: "))
	(if (and p1 p2)
		(progn
			(if (= (car p1) (car p2))
				(setq therows 2 thecols 1 drows (- (cadr p2) (cadr p1)) dcols (- (cadr p2) (cadr p1)))
				(if (= (cadr p1) (cadr p2))
					(setq therows 1 thecols 2 drows (- (car p2) (car p1)) dcols (- (car p2) (car p1)))
					(setq therows 2 thecols 2 drows (- (cadr p2) (cadr p1)) dcols (- (car p2) (car p1)))
				)
			)
			(vla-sendcommand
				(vla-get-activedocument (vlax-get-acad-object))
				(strcat "array\rp\r\rR\rROW\r" (itoa therows) "\n" (rtos drows 2 10) "\n\nCOL\r" (itoa thecols) "\r" (rtos dcols 2 10) "\r\r")
			)
		)
	)
	(princ "\nwww.tankhanh.com.vn")
	(princ)
)
www.tankhanh.com.vn
0 Likes
Message 3 of 7

GrantsPirate
Mentor
Mentor

The new associative array is easier to use, not harder.  Turn on the Ribbon to see just how easy it is to use.


GrantsPirate
Piping and Mech. Designer
EXPERT ELITE MEMBER
Always save a copy of the drawing before trying anything suggested here.
----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.

0 Likes
Message 4 of 7

lemanhhung0302
Contributor
Contributor

Thank you, mr GrandsPirate

I never use Ribbon before

www.tankhanh.com.vn
0 Likes
Message 5 of 7

Anonymous
Not applicable

How can we combine the following lispi with AR.lsp. I want the result to be a direct intermediate distance.

 

(defun c:ds (/ d a b)
(if (setq d (getdist "\nDist:"))
(alert (strcat "X= " (rtos (setq a (/ d 1200)) 2 2)
"\nY= " (rtos (setq b (1+ (fix a))) 2 2) "\nZ= " (rtos (/ (- d 122) b) 2 2)))
) (princ)
)

0 Likes
Message 6 of 7

Anonymous
Not applicable

I'm using it for the array command.

but I couldn't combine two lispis.

 

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

)

l

)

(if

(and

(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

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

)

0 Likes
Message 7 of 7

Anonymous
Not applicable

my favourite

 

(defun c:tt (/ ss p1 p2 num ang dst dst2)
(if (and (setq ss (ssget "_:L"))
(setq p1 (getpoint "\nSpecify first point: "))
(setq p2 (getpoint p1 "\nSpecify next point: "))
(progn (initget 6) (setq num (getint "\nSpecify number of copies: ")))
)
(progn
(setq ang (angle p1 p2)
dst (distance p1 p2)
dst2 0.
)
(repeat num (command "_.copy" ss "" "_non" p1 "_non" (polar p1 ang (setq dst2 (+ dst dst2)))))
)
)
(princ)
)

0 Likes