Copy / Paste / Rotate several time without redefine object or base point.

Copy / Paste / Rotate several time without redefine object or base point.

m.lharidon
Enthusiast Enthusiast
9,613 Views
19 Replies
Message 1 of 20

Copy / Paste / Rotate several time without redefine object or base point.

m.lharidon
Enthusiast
Enthusiast

Hello community!

 

I would like to use a function close to MOCORO (copy/paste rotate), but with several copies.

It would be like:

 

Click function / select object/select point base ... then click paste/click rotate until the end of the function.

 

Can you help me?

 

Thanks by advance!

 

Max

 

 

 

 

0 Likes
Accepted solutions (3)
9,614 Views
19 Replies
Replies (19)
Message 2 of 20

gotphish001
Advisor
Advisor

Select an object. Click on a grip for your base point. Space bar toggles thru move, rotate, scale. If you use control on the move icon it will copy instead. I think that is as close as you are going to get without writing a lisp or finding one. No matter what, you still will need a second click in there because autocad can't guess if you want to copy or rotate or just move each time.



Nick DiPietro
Cad Manager/Monkey

0 Likes
Message 3 of 20

Kent1Cooper
Consultant
Consultant
Accepted solution

@m.lharidon wrote:

.... 

Click function / select object/select point base ... then click paste/click rotate until the end of the function.

.... 


If by "select object" you really mean only one  object, try this:

(defun C:CBPRM (/ e p); = CopyBase and Paste/Rotate Multiple
  (if
    (and
      (setq e (car (entsel "\Object to Paste/Rotate Multiple times: ")))
      (setq p (getpoint "\nBase point for Pasting & Rotation: "))
    ); and
    (progn ; then
      (command "_.copybase" p e "")
      (while (setq p (getpoint "\nPaste base point or <exit>: "))
        (command
          "_.pasteclip" p
          "_.rotate" "_last" "" p pause
        ); command
      ); while
    ); progn
  ); if
  (princ)
); defun

If you might sometimes want to select more than one  object, that's more complicated [because the selection in the Rotate command needs to involve an indeterminate number of objects], but doable -- there are a couple of ways I can imagine it could be done.

 

Kent Cooper, AIA
Message 4 of 20

m.lharidon
Enthusiast
Enthusiast

Thanks but I manage the basic fonction, I looked for a productivity tool (allInOne).

 

However thanks for your time.

0 Likes
Message 5 of 20

m.lharidon
Enthusiast
Enthusiast

Hello,

 

It looks pomising but.

 

I copy your macro on my fonction then when i click I have the linked image situation.

(I work in lighting, The application is to copy several spot on a track but with different orientations).

 

I can't find where it bug.

 

Thanks for your time.

 

ML

0 Likes
Message 6 of 20

Kent1Cooper
Consultant
Consultant

@m.lharidon wrote:

.... 

I copy your macro on my fonction then when i click I have the linked image situation.

....


It's not a macro, so if you're putting it into something like a Tool Palette button, it's not written for that.  You can either:

A)  Paste it into a plain-text editor such as Notepad, save it to a file with a .lsp filetype ending, and APPLOAD that file.

 

B)  Paste it into a plain-text editor such as Notepad, remove all semicolons and whatever follows them on all lines, Copy the remaining code to the clipboard, and Paste that in at the AutoCAD command line.  [And if you get a line like this:

(_> )

just hit Enter to register that last parenthesis.]

 

Either way will only define  the command -- they will not start  it.  You will need to enter the CBPRM command name.  You can put that  into a Tool Palette button as a macro, if you like.

Kent Cooper, AIA
Message 7 of 20

Anonymous
Not applicable

Very simple, but try this:

(defun c:CR (/ ss p1 p2)
  (princ "\n >>Select objects<<: ")
  (if
    (setq ss (ssget))
    (if
      (setq p1 (getpoint "\nClick the Point: "))
      (progn
	(command "_.COPY" ss "" p1 p1)
        (princ "\nSecond point: ")
        (command "_.MOVE" ss "" p1 pause) 
        (setq P2 (getvar "LASTPOINT")) 
        (princ "\nAngle:") 
        (command "_.ROTATE" ss "" P2 "b" "0" pause)
      ) 
    ) 
    (prompt "\nNo object selected!!") 
  ) 
  (princ) 
)
(Prompt "\n Type CR  ")

Júnior Nogueira.

Por favor,  Aceitar como Solução se meu post te ajudar.

Please Accept as Solution if my post helps you.

0 Likes
Message 8 of 20

m.lharidon
Enthusiast
Enthusiast

Thanks a lot!!!

0 Likes
Message 9 of 20

m.lharidon
Enthusiast
Enthusiast

Thanks a lot.

 

Two small questions:

 

How can I create a short cut for it? to put in the tool bar?

If I want to define automatically the base point as gravity point of my block. is it possible?

 

Thanks.

0 Likes
Message 10 of 20

Kent1Cooper
Consultant
Consultant
Accepted solution

@m.lharidon wrote:

....How can I create a short cut for it? to put in the tool bar?

If I want to define automatically the base point as gravity point of my block. is it possible?

....


Help will tell you how to create a Tool Palette button.

 

If the object will always be a Block, you can replace this line:

 

(setq p (getpoint "\nBase point for Pasting & Rotation: "))

 

with this:

(setq p (cdr (assoc 10 (entget e))))

 

but that's the bare-bones way -- if needed, it could be enhanced to check that you did pick a Block, and even to ask you again if you picked something else, or missed.

Kent Cooper, AIA
0 Likes
Message 11 of 20

m.lharidon
Enthusiast
Enthusiast

So great!! Thanks it is exactly what i looked for!! 🙂 (So happy)

0 Likes
Message 12 of 20

m.lharidon
Enthusiast
Enthusiast

Hello Kent,

 

I tried to use your trick on this lisp not to have to define base point every time, but I can't make it work.

 

Can you help me?

 

Thanks.

0 Likes
Message 13 of 20

Kent1Cooper
Consultant
Consultant

@m.lharidon wrote:

.... 

I tried to use your trick on this lisp not to have to define base point every time, but I can't make it work.

....


I'm not sure what you mean by my "trick" in relation to that routine [which doesn't involve the Rotate aspect of this thread] -- from which message?  Do you want to re-use the same selection set and basepoint for multiple paste-arrays within one running of the command?  That could be pretty simple, pulling the selection and basepoint out on their own for re-use, and putting the point designations inside a (while) loop.

Kent Cooper, AIA
0 Likes
Message 14 of 20

m.lharidon
Enthusiast
Enthusiast

Sorry, I wasn't clear.

This lips is about to copy n time object between to point. I would like to apply it to block and so, i d like to take automaticly the block base point.

 

Then i try to replace

 (setq p (getpoint "\n Specify Base point of objects :"))

By 

(setq p (cdr (assoc 10 (entget e)))

But It doesn't work. I don't understand what i missed.

 

Thanks.

0 Likes
Message 15 of 20

Kent1Cooper
Consultant
Consultant

@m.lharidon wrote:

 

….

But It doesn't work. ....


"It doesn't work" is never enough information.  What are the symptoms?  Does the file not load?  Does it load, but the command name isn't recognized?  Does it take the command name, but something happens that you don't expect?  Something doesn't happen that you do expect?  Etc., etc.

 

If it pastes things but in the wrong place(s), do you have running Object Snap modes on?  It was always a bare-bones routine, so it didn't yet include controlling for that, but it's easy to add.

Kent Cooper, AIA
0 Likes
Message 16 of 20

m.lharidon
Enthusiast
Enthusiast

Hello,

 

Sorry for the imcomplete information:

So:

-the lisp load correctly

-The command is reconized

-It runs until "object selection" i select it then nothing.

 

Thanks.

 

ML

 

 

0 Likes
Message 17 of 20

Kent1Cooper
Consultant
Consultant

@m.lharidon wrote:

....

-the lisp load correctly

-The command is reconized

-It runs until "object selection" i select it then nothing.

.... 


 

Hard to say without seeing your end-result code -- maybe something went awry in copying/pasting.  This version works for me:

(defun C:CBPRM (/ e p); = CopyBase and Paste/Rotate Multiple
  (if
    (and
      (setq e (car (entsel "\Object to Paste/Rotate Multiple times: ")))
      (setq p (cdr (assoc 10 (entget e))))
    ); and
    (progn ; then
      (command "_.copybase" p e "")
      (while (setq p (getpoint "\nPaste base point or <exit>: "))
        (command
          "_.pasteclip" p
          "_.rotate" "_last" "" p pause
        ); command
      ); while
    ); progn
  ); if
  (princ)
); defun
Kent Cooper, AIA
0 Likes
Message 18 of 20

m.lharidon
Enthusiast
Enthusiast

Hello,

 

Yes it work perfectly for this Lisp (CBPRM) but i tried to apply the "select base point" line to an other lisp (cm2p attached in my previous message.).

 

This is what i looked for. why this selection doesn't work in this lisp but perfectly works on yours.

 

ML

0 Likes
Message 19 of 20

Kent1Cooper
Consultant
Consultant
Accepted solution

@m.lharidon wrote:

.... 

Yes it work perfectly for this Lisp (CBPRM) but i tried to apply the "select base point" line to an other lisp (cm2p attached in my previous message.).

 

This is what i looked for. why this selection doesn't work in this lisp but perfectly works on yours.

....


 

It's the difference between single-object  selection with (entsel) and multiple-object  selection with (ssget).  The CM2P command is set up for multiple objects [if you want -- you can stop at only one], and there is no 'e' variable [the single object in CBPRM] from which to extract that insertion point.  IF  you will always use it to select only one object, and IF  that object will always be something with an (assoc 10) entry  in its entity data [such as a Block's or Text/Mtext object's insertion point, or a Line's or Polyline's start point, or an Arc's or Circle's center point], you could try replacing this line:


    (setq p (getpoint "\n Specify Base point of objects :"))

 

with [instead of the substitution in CBPRM using the 'e' entity name] this:


    (setq p (cdr (assoc 10 (entget (ssname ss 0)))))

 

to get it from the first [and only] object in the selection set.

 

But you could also change the selection  part to use (entsel) instead of (ssget), as in the other command.

Kent Cooper, AIA
0 Likes
Message 20 of 20

m.lharidon
Enthusiast
Enthusiast

Exaclty what i wanted to know.

 

Once again, thanks a lot for your time and your patience!

0 Likes