Jump to content

copy & paste to original location multiple times


Recommended Posts

Posted

Any user here has lisp to copy an entity/entities & paste to the same location multiple times.

 

lisp to run in this manner

 

- select entity/entities

- key in the number (to indicate how many to paste)

- Enter

 

(Please don't require user to click a base point)

Posted

I wonder what is the wisdom behind copying the same objects in the same original location many times?

Posted
I wonder what is the wisdom behind copying the same objects in the same original location many times?

 

Tharwat sir, the enity/entities are a reference item. I need to insert this reference item into various blocks in the same location. Therefore I need multiples of this enity/entities

Posted
Can you give a clear example of what you are after?

 

Tharwat sir. Here is a photo & dwg file.

I fogot to add in the photo, that preferable no base point input is required from user. Just paste the multiples on the top of the original.

PASTE MULTIPLE FUNCTION.jpg

PASTE MULTIPLE FUNCTION.dwg

Posted

Try this;

(defun c:Test (/ cm ss in)
 (if (and (setq ss (ssget "_:L"))
          (setq in (getint "\nSpecify number of copies :"))
     )
   (progn
     (setq cm (getvar 'CMDECHO))
     (setvar 'CMDECHO 0)
     (repeat in
       (command "_.COPY" ss "" '(0. 0.) '(0. 0.))
     )
     (setvar 'CMDECHO cm)
   )
 )
 (princ)
)

Posted

@ Tharwat: Maybe add "_non" (2x) just in case...

Posted
@ Tharwat: Maybe add "_non" (2x) just in case...

 

You are right Roy, honestly I have noticed that after a few minutes of posting the codes and intended to wait for OP's reply if they might need any changes and would cover that issue in the next mods.

Posted
Try this;

(defun c:Test (/ cm ss in)
 (if (and (setq ss (ssget "_:L"))
          (setq in (getint "\nSpecify number of copies :"))
     )
   (progn
     (setq cm (getvar 'CMDECHO))
     (setvar 'CMDECHO 0)
     (repeat in
       (command "_.COPY" ss "" '(0. 0.) '(0. 0.))
     )
     (setvar 'CMDECHO cm)
   )
 )
 (princ)
)

 

Tharwat sir. work as i wanted. Thanks so much.

 

What is "_non" (2x) about. important?

Posted
Tharwat sir. work as i wanted. Thanks so much.

 

You are welcome.

 

What is "_non" (2x) about. important?

Like the following adds and this should ignore the settings of your object snap settings to place the newly created objects in their correct place.

(defun c:Test (/ cm ss in)
 (if (and (setq ss (ssget "_:L"))
          (setq in (getint "\nSpecify number of copies :"))
     )
   (progn
     (setq cm (getvar 'CMDECHO))
     (setvar 'CMDECHO 0)
     (repeat in
       (command "_.COPY" ss "" "_none" '(0. 0.) "_none" '(0. 0.))
     )
     (setvar 'CMDECHO cm)
   )
 )
 (princ)
)

Posted

Another :

 

(defun c:test ( / ss n i e )

 (vl-load-com)

 (if 
   (and
      (setq ss (ssget "_:L"))
      (not (initget 7))
      (setq n (getint "\nHow many copies : "))
   )
   (repeat (setq i (sslength ss))
     (setq e (ssname ss (setq i (1- i))))
     (repeat n
       (vla-copy (vlax-ename->vla-object e))
     )
   )
 )
 (princ)
)

Posted

Thanks marko_ribar. This works as well. :)

 

Another :

 

(defun c:test ( / ss n i e )

 (vl-load-com)

 (if 
   (and
      (setq ss (ssget "_:L"))
      (not (initget 7))
      (setq n (getint "\nHow many copies : "))
   )
   (repeat (setq i (sslength ss))
     (setq e (ssname ss (setq i (1- i))))
     (repeat n
       (vla-copy (vlax-ename->vla-object e))
     )
   )
 )
 (princ)
)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...