TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: litss on June 30, 2010, 08:31:06 AM

Title: Why (command "copy") can't act as the same as "real" copy?
Post by: litss on June 30, 2010, 08:31:06 AM
Why (command "copy") can't act as the same as "real" copy?

Typing the "copy" in the CAD, I can do Muti-copy. While typing (command "copy") or (vl-cmdf "copy") or (command "copy" "pause")...ect. I can do copy only one time, then it'll stop automatically. Does anyone know why?

Actually, I want to create a lisp to rename some frequently-used command in stead of editing the PGP file. But it seems that (command ...) or (vl-cmdf ...) could not act right as the "real" one. Confusing...

And, the (command "copy") will prompt like this:

Quote
Command: (command "copy")
copy nil

Select objects: 1 found

How can I kill the showing of "nil"?
 
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: kpblc on June 30, 2010, 08:39:47 AM
Perhaps this:
Code: [Select]
(defun c:test-copy ()
  (command "_.cop" "_m")
  (while (/= (getvar "cmdactive") 1)
    (command pause)
    ) ;_ end of while
  (princ)
  ) ;_ end of defun
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: jitupnair on June 30, 2010, 09:18:52 AM
Another method

(command "copy" (ssget) "" "M")
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: Keith™ on June 30, 2010, 09:34:12 AM
How can I kill the showing of "nil"?

Code: [Select]
(setvar "nomutt" 1)

Explanation and C# usage can be found here (http://through-the-interface.typepad.com/through_the_interface/2008/09/no-muttering-at.html)
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: litss on July 01, 2010, 12:40:06 AM
thx all u guys.

"nomutt" couldn't work
Quote
Command: (setvar "NOMUTT" 1)
1
(command "copy")
copy nil
*Cancel*

Code: [Select]
(command "copy" (ssget) "" "M") works. But still showing the "nil".
Quote
(command "copy" (ssget) "" "M")
copy    M nil
*Cancel*

Code: [Select]
(command "_.cop" "_m") couldn't work. Maybe it should be _.copy.



Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: LE3 on July 01, 2010, 12:49:24 AM
Code: [Select]
;;; copy multiple
(defun C:CM  (/ ss)
  (if (setq ss (ssget))
    (vl-cmdf "_.copy" ss "" "_m"))
  (princ))
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: litss on July 01, 2010, 12:55:02 AM
Actually I don't mean to find a way to deal with "copy" only, I need a common way to deal with all commands. Just don't want to revise the PGP file.
Here's the frame of my routine:
Code: [Select]
(defun c:test ()
(setq cnamlst (list '("copy" "c") '("move" "v") '("find" "ff") ...));setq
(setq n 0)
(repeat (length cnamlst)
(setq Fname (car (nth n cnamlst)))
(setq Sname (last (nth n cnamlst)))
(eval (list 'defun (read (strcat "c:" Sname)) '() (list 'command Fname)));eval
(setq n (1+ n))
);repeat
);end of defun

Apparently, the (command ...) couldn't work right as the real command. I just don't know how the "PGP" file do the renaming.
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: Kerry on July 01, 2010, 01:31:09 AM

It will be quicker and safer to add the alias's to the end of your pgp file ..
believe me.

Simply have your personal alias's in a file that you can paste onto the end of the default PGP, you DON"T need to edit the pgp entrys.


and further ;
if this is for sharing, keep your users happy by NOT overriding their accustomed shortcuts
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: alanjt on July 01, 2010, 08:50:31 AM
I just have short LISP routine that keeps all my pgp aliases and appends them to the end of my acad.pgp. This way I can run it once and never fuss again.
Title: Re: Why (command "copy") can't act as the same as "real" copy?
Post by: litss on July 01, 2010, 09:38:50 PM
Well, Kerry, alanjt, U r right. I should make some small revision.

It's easy to add aliases to the PGP file by a short routine, but it's hard to automatically delete them while shutting down the AUTOCAD. Maybe I have to manually run another routine to do the delete.

I make this routine just for some one who may use others' computers temperately and don't wanna change the owner's accustomed shortcuts. When it is needed, just drag the lsp file into the CAD. While closing, nothing changed.