Author Topic: Lisp for "copy" command  (Read 5208 times)

0 Members and 1 Guest are viewing this topic.

carmi

  • Newt
  • Posts: 27
Lisp for "copy" command
« on: May 11, 2017, 12:40:45 PM »
hi,
there is a lisp similar to "copy" command of the Autocad?
In particular, i look for a lisp who make copy array fit as picture attached below.
I need this lisp because my cad software not have this command.
Thank you
Regards
Carmelo

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp for "copy" command
« Reply #1 on: May 11, 2017, 12:58:46 PM »
You don't have the 'Array' option as part of the standard 'Copy' command?

Current settings:  Copy mode = Multiple
Specify base point or [Displacement/mOde] <Displacement>:
Specify second point or [Array] <use first point as displacement>: A
Enter number of items to array: 10

Specify second point or [Fit]: F

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #2 on: May 11, 2017, 02:02:00 PM »
I not have this option in my copy command...
If I had this chance i would not ask here ;)
I use NanoCad 5

ChrisCarlson

  • Guest
Re: Lisp for "copy" command
« Reply #3 on: May 11, 2017, 02:17:15 PM »
Divide command with block insert?

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #4 on: May 11, 2017, 03:38:25 PM »
Divide command with block insert?
Yes, i tried that command but actually "copy array fit" is more intuitive...
There are lisp file of the autocad command?

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Lisp for "copy" command
« Reply #5 on: May 11, 2017, 05:10:57 PM »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #6 on: May 12, 2017, 04:18:15 AM »
Try 3parray.lsp posted here :
https://www.theswamp.org/index.php?topic=49028.msg541810#msg541810
Hi, i tried but at the end i have this error:
"Array Endpoint: GRREAD not implemented"
Some help?

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #7 on: May 17, 2017, 04:09:33 AM »
Can someone else help me?
Thanks

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Lisp for "copy" command
« Reply #8 on: May 17, 2017, 05:25:29 AM »
Does your CAD have COPYMODE variable? If so, set it to 1 and then when you initialize COPY command pick base point, move mouse in desired direction (ortho optional) and just type distances consequently... It this doesn't work, maybe try to write small lisp like this one :

Code: [Select]
(defun c:array-new ( / ss n p1 p2 k v l )

  (vl-load-com)

  (setq ss (ssget "_:L"))
  (initget 7)
  (setq n (getint "\nNumber of copies : "))
  (initget 1)
  (setq p1 (getpoint "\nPick or specify base point : "))
  (initget 1)
  (setq p2 (getpoint p1 "\nPick or specify direction point (distance between copies) : "))
  (setq v (mapcar (function -) p2 p1))
  (setq k 0)
  (if ss
    (repeat n
      (setq k (1+ k))
      (foreach obj (if (null l) (setq l (mapcar (function vlax-ename->vla-object) (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))))) l)
        (vla-move (vla-copy obj) (vlax-3d-point (list 0 0 0)) (vlax-3d-point (mapcar (function *) v (list k k k))))
      )
    )
  )
  (princ)
)
« Last Edit: May 17, 2017, 09:01:13 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #9 on: May 17, 2017, 10:47:41 AM »
I can make multiple and single copies in my cad, but i need "fit" mode as Autocad copy command, because with my CAD i not have "fit" mode and it is very useful to me.
Your lisp code gives me this error: "invalid SSGET mode string".
If i change   (setq ss (ssget "_:L"))    with  (setq ss (ssget C)) i solve it but i have this other error: error: invalid argument type: vla-object: nil
Thank you for help me


BKT

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #10 on: May 17, 2017, 11:38:13 AM »
Maybe NanoCAD doesn't support all LISP or VLISP functions.  What happens if you try this:

Code: [Select]
(defun c:test (/ ent ent2 p1 p2 p3 pt dv d a n)

(setq cmde (getvar "CMDECHO"))
(setq osm (getvar "OSMODE"))
(setvar "CMDECHO" 0)

(setq ent (entsel "\nSelect Object: ")
      pt (getpoint "\nSelect Point On Object: ")
      p1 (getpoint "\nSelect Start Point: ")
      p2 (getpoint "\nSelect End Point: ")
      dv (getint "\nEnter Number Of Copies: ")
      d (/ (distance p1 p2) (1- dv))
      a (angle p1 p2)
)

(setvar "OSMODE" 0)

(command "._copy" ent "" pt p1)
(setq ent2 (entlast))

(setq n 0)
  (while (< n dv)
  (setq p3 (polar p1 a (* d n)))
  (command "._copy" ent2 "" p1 p3)
  (setq n (1+ n))
  )

(entdel ent2)

(setvar "OSMODE" osm)
(setvar "CMDECHO" cmde)

(princ)

)

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #11 on: May 17, 2017, 11:53:58 AM »
Maybe NanoCAD doesn't support all LISP or VLISP functions.  What happens if you try this:
With other lisp i not have problem...

With your code, when enter number of copies, open hatch command!  :grumpy:

BKT

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #12 on: May 17, 2017, 12:00:21 PM »
Well, that ain't right...  sorry 'bout that! :straight:

carmi

  • Newt
  • Posts: 27
Re: Lisp for "copy" command
« Reply #13 on: May 17, 2017, 12:16:38 PM »
I found a lisp code of Alanjt in this post: http://www.theswamp.org/index.php?topic=37459.msg424991#msg424991
Its a good lisp code but isn't what i was looking for...