Author Topic: lisp by Lee-MAC found at the swamp  (Read 2835 times)

0 Members and 1 Guest are viewing this topic.

Fabricio28

  • Swamp Rat
  • Posts: 666
lisp by Lee-MAC found at the swamp
« on: August 30, 2014, 12:50:31 PM »
I guys,
I've found that great code and I need to do little modfication.

I'd like to activate osnap endpoint to finish the comand.

Anybody Can help me out please??
Code: [Select]
;; by Lee-MAC found at the swamp
 
(defun c:recarr ( / ss->list copyv dx dy gr i1 i2 nx ny obs obx oby p0 px py vx vy ) (vl-load-com)
 
(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 (P0): "))
 
(setq px (getpoint "\nArray X-Vector (Px): " p0))
 
(setq py (getpoint "\nArray Y-Vector (Py): " p0))
 
)
 
(progn
 
(setq vx (mapcar '- px p0) dx (distance '(0. 0. 0.) vx)
 
vy (mapcar '- py p0) dy (distance '(0. 0. 0.) vy)
 
)
 
(princ "\nArray Endpoint: ")
 
(while (= 5 (car (setq gr (grread 't 13 0)))) (redraw)
 
(setq obx (car (mapcar 'vla-delete obx))
 
oby (car (mapcar 'vla-delete oby))
 
gr (mapcar '- (cadr gr) p0)
 
i1 (inters '(0. 0. 0.) vx gr (mapcar '+ gr vy) nil)
 
i2 (inters '(0. 0. 0.) vy gr (mapcar '+ gr vx) nil)
 
nx (fix (/ (caddr (trans i1 1 vx)) dx))
 
ny (fix (/ (caddr (trans i2 1 vy)) dy))
 
obx (copyv obs (abs nx) (mapcar (if (minusp nx) '- '+) vx))
 
oby (copyv (append obs obx) (abs ny) (mapcar (if (minusp ny) '- '+) vy))
 
)
 
(grvecs (list -3 '(0. 0. 0.) i1 i1 gr '(0. 0. 0.) i2 i2 gr)
 
(list
 
(list 1. 0. 0. (car p0))
 
(list 0. 1. 0. (cadr p0))
 
(list 0. 0. 1. (caddr p0))
 
(list 0. 0. 0. 1.)
 
)
 
)
 
)
 
)
 
)
 
(redraw) (princ)
 
)

Thank in advance

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: lisp by Lee-MAC found at the swamp
« Reply #1 on: August 30, 2014, 01:14:02 PM »
I see no need for Object Snap in this instance, as the precise position of the final picked endpoint has no effect on the position of the arrayed objects, it simply dictates the number of objects in the array.

Fabricio28

  • Swamp Rat
  • Posts: 666
Re: lisp by Lee-MAC found at the swamp
« Reply #2 on: August 30, 2014, 06:41:08 PM »
I agree with you mr. Lee. Sorry for my stupid question  :embarrassed:

I'm trying to add your code in my task. 
Is there how to insert how many objects was inserted??

Could you help me?

Regards

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: lisp by Lee-MAC found at the swamp
« Reply #3 on: August 31, 2014, 06:04:28 AM »
I agree with you mr. Lee. Sorry for my stupid question  :embarrassed:

No need to apologise!  :-)

I'm trying to add your code in my task. 
Is there how to insert how many objects was inserted??

The number of copies in each direction is given by the absolute values of the nx & ny variables.

Fabricio28

  • Swamp Rat
  • Posts: 666
Re: lisp by Lee-MAC found at the swamp
« Reply #4 on: August 31, 2014, 09:03:03 AM »
Hi,

would you mind to help me insert the numbers of copies nx + ny?

Thank in advance.



CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lisp by Lee-MAC found at the swamp
« Reply #5 on: August 31, 2014, 10:48:54 AM »
Hint
(princ (* (1+ nx)(1+  ny)))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Fabricio28

  • Swamp Rat
  • Posts: 666
Re: lisp by Lee-MAC found at the swamp
« Reply #6 on: August 31, 2014, 11:53:37 AM »
Thak you CAB!