Copy multiple with point filter

Copy multiple with point filter

moon47usaco
Contributor Contributor
1,319 Views
5 Replies
Message 1 of 6

Copy multiple with point filter

moon47usaco
Contributor
Contributor

I have a simple lisp that copies one object in only the X direction.

 

I would like to be able to copy the same object to multiple locations in only the X direction.

 

(defun C:CX( / )
(command "COPY" (ssget) "" (getpoint) ".X" (getpoint) "0")
(princ)
)

 

I have tried to use a while loop but it seems you can not use the loop inside a command prompt

 

(defun C:CXM( / )
(initcommandversion)
(command "COPY" (ssget) "" (getpoint) (while t (".X" (getpoint) "0")))
)

 

How do I get the last copt to prompt to always be filtered in X?

0 Likes
Accepted solutions (1)
1,320 Views
5 Replies
Replies (5)
Message 2 of 6

SeeMSixty7
Advisor
Advisor

Welcome to the AutoDesk Forum.

 

Try this. Basically you break the command in two pieces. on inside the while loop and the other to start the command.

 

(defun C:CXM( / )
(initcommandversion)
(command "COPY" (ssget) "" (setq xpoint (getpoint)))
(while (= (getvar "CMDACTIVE") 1)
(command ".X" xpoint pause)
)
)

 

 

Good Luck

 

Message 3 of 6

Ranjit_Singh
Advisor
Advisor
Accepted solution

I do not understand the question entirely. But from what little I understand, I think this is what you want, I may be wrong.

(defun c:somefunc  (/ ss1 sp bp)
 (setq ss1 (ssget)
       bp  (getpoint "\nSpecify base point :"))
 (while (setq sp (getpoint "\nPick second point :"))
  (command "._copy" ss1 "" bp (list (car sp) (cadr bp)) "")))
Message 4 of 6

moon47usaco
Contributor
Contributor

Yes that is what I am after, thank you.

 

Trying to copy one object across the screen several times in only the X direction is what this seems to accomplish... =]

0 Likes
Message 5 of 6

Ranjit_Singh
Advisor
Advisor

I believe @SeeMSixty7 has a really elegant solution. Simply change the X in his code to Y

(defun C:CXM( / xpoint)
(initcommandversion)
(command "COPY" (ssget) "" (setq xpoint (getpoint)))
(while (= (getvar "CMDACTIVE") 1)
 (command ".Y" xpoint pause)))
Message 6 of 6

Kent1Cooper
Consultant
Consultant

Another approach, not requiring any code:

 

Turn ORTHO [F8] and  OBJECT SNAP TRACKING [F11] on

COPY <select objects> <Enter>

Multiple option [in newer versions, mOde option followed by Multiple option if not already in effect]

<Base point>

Then for displacements not involving reference to other locations such as with Osnap, just pick, as long as the cursor is more horizontal from the base point than vertical, or type in distances if you know them with the cursor "dragged" in the right horizontal direction.  For the equivalent of Osnap-with-.X-filtering operation, with appropriate running Osnap mode(s) on, hover over each snappable location until the little green cross appears on it, then drag the cursor down or up from there until the vertical projection from there locks onto the horizontal projection from the base point [you'll see what the Copy result will be], and pick; repeat as desired.

 

It takes a little getting used to, but it's pretty nifty.

 

Kent Cooper, AIA
0 Likes