Change copy mode in lisp

Change copy mode in lisp

Nathan_Tigner
Advocate Advocate
1,199 Views
7 Replies
Message 1 of 8

Change copy mode in lisp

Nathan_Tigner
Advocate
Advocate

Hi guys,

 

This is probably a stupid question and is easy to fix but I havn't found the answer yet. 

 

I use a lisp for some command shortcuts so I don't ever have to edit the pgp file that comes with cad.

 

One of them is (defun c:C() (command "COPY")), yes, I have one for circle since I am replacing the default C for circle. My question is, doing it this way puts the copy command in displacement mode, how would I switch it to multiple mode in the lisp?

0 Likes
Accepted solutions (1)
1,200 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

This way you often launch an older version (LISP) of the command than the current one (AutoCAd). Yes, there are many differences.

So I would recommend getting back to PGP. It serves pretty well its purpose. 

 

If you really need it, usually you can use the (initcommandversion) predecessor. But it's not always working...

0 Likes
Message 3 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

How 'bout this?

(defun C:C (/ ss)
  (if (setq ss (ssget))
    (command "_.copy" ss "" "_multiple")
  )
)
Kent Cooper, AIA
0 Likes
Message 4 of 8

Nathan_Tigner
Advocate
Advocate

Boom. Thank you so much!

0 Likes
Message 5 of 8

john.kaulB9QW2
Advocate
Advocate

I don't see what's wrong with:

(defun C:c ()
  (command "_.copy") )

But if you're evaluating on to start the copy command or not with IF, wouldn't you just use vl-cmdf (because vl-cmdf evaluates each argument before passing the command to AutoCAD, the invalid selection set is detected, and the command is not executed.)?

(defun C:c ()
  (vl-cmdf "_.copy" (ssget) "_multiple") )

 

another swamper
0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant


@john.kaulB9QW2 wrote:

I don't see what's wrong with:

(defun C:c ()
  (command "_.copy") )

But if you're evaluating on to start the copy command or not with IF, wouldn't you just use vl-cmdf (because vl-cmdf evaluates each argument before passing the command to AutoCAD, the invalid selection set is detected, and the command is not executed.)? ....

Message 1 explains what's wrong with your first code window -- that's the OP's whole point.

 

Your (vl-cmdf) needs object selection to be concluded in order to work:

(defun C:C ()
  (vl-cmdf "_.copy" (ssget) "" "_multiple")
)

But it's not where my mind goes first, having done this so long before that function existed....

Kent Cooper, AIA
0 Likes
Message 7 of 8

john.kaulB9QW2
Advocate
Advocate

Yes, those quotes are needed (I must have been too ambitious in my typing).

 

Understood. 

 

NOTE: when using that if-construct you are used to, I was always taught to use a "boolean variable". So instead of typing
(if (setq ss (ssget...)
the proper syntax is:

(setq selectionset (ssget))
(if selectionset
...

because it offers greater readability; -i.e. the symbol nil in lisp has at least three different jobs.

1. to represent an empty list. '()
2. falsity. (= 1 0)
3. failure.

because the proper syntax is being less ambiguous. In other languages, that if-construct you are using can lead to bigger problems.

another swamper
0 Likes
Message 8 of 8

ВeekeeCZ
Consultant
Consultant

Sort of generic solution is using (initcommand...) but  in general it is more convenient to use the pgp file for this job.

 

(defun c:c () (initcommandversion) (command "_.copy") (princ))
0 Likes