Jump to content

Lisp to copy,paste from one to another drawing...


amb2301

Recommended Posts

Hi Friends, 

       I need a lisp like....it should copy all the magenta color objects from drawing1.dwg (currently opened file)& then open a new drawing file & continue to paste that copied magenta objects in new drawing in same coordinates....

 

 

 

 

 

Link to comment
Share on other sites

13 hours ago, amb2301 said:

Hi Friends, 

       I need a lisp like....it should copy all the magenta color objects from drawing1.dwg (currently opened file)& then open a new drawing file & continue to paste that copied magenta objects in new drawing in same coordinates....

 

 

 

 

 

use filter command

Link to comment
Share on other sites

If what you want is a simple copy/paste you don't need lisp as suggested by Bigal and lsh. I have a couple of dedicated buttons for that in one of my toolbars.

 

CopyPaste.jpg.267e1510f866eed80eee03b2d1820026.jpg

 


***MENUGROUP=RlxMnu

***TOOLBARS
**RLX-TB1
               [_Toolbar("RLX-TB1", _Bottom, _Show, 0, 0, 1)]
ID_Bcopy       [_Button("Copy With Basepoint 0,0", "bcopy.bmp", "ICON_16_BLANK")]^C^C_copybase;0,0;
ID_Bpaste      [_Button("Paste with Basepoint 0,0", "bpaste.bmp", "ICON_16_BLANK")]^C^C_pasteclip;0,0;
ID_GetBcopy    [_Button("Copy With Get Basepoint", "bcopy_get.bmp", "ICON_16_BLANK")]^C^C_copybase;
ID_GetBpaste   [_Button("Paste with Get Basepoint", "bpaste_get.bmp", "ICON_16_BLANK")]^C^C_pasteclip;

***HELPSTRINGS
ID_BCOPY       [Copy with Basepoint 0,0]
ID_BPASTE      [Paste with basepoint 0,0]
ID_GetBCOPY    [Copy with Get Basepoint]
ID_GetBPASTE   [Paste with Get basepoint]

 

This is just basic AutoCad. If you need a pimped up  version do a search on this site for RlxPaste.lsp. If you need to copy objects to many drawings without opening the link I posted before to Lee's site is what you need. But in all cases you need to do the selection yourself , either by hand (qselect) of with (ssget "x" '((62 . 6))) although this only works on objects that have a color property (if object is color bylayer , object will have no 62 group)

 

🐉

 

 

 

Bcopy.bmp bcopy_get.BMP Bpaste.bmp bpaste_get.BMP RlxMenu.mns

  • Like 1
Link to comment
Share on other sites

Hi All, 

Thank you so much for all your valuble suggestions,

actually i would like to learn the lisp....i tried untill selecting the required objects & copied to clipboard using simple command methods in lisp,

 

Now i need to open a new drawing & paste those objects there...please help me on that part of lisp

 

(defun c:ly ()

(command "grid" "off")
(command "-layer" "f" "*" "")
(command "-layer" "t" "F_CABLE_AERIAL" "")
(sssetfirst nil (ssget "_x" '((62 . 6))))
(command "")
(command "_.copyclip" "Previous" "")




;;;(vla-Add (vla-get-Documents (vlax-get-acad-object)) "acad.dwt")
;;(command "new" "C:\Users\f\appdata\local\autodesk\autocad 2014\r19.1\enu\template\acad.dwt")
;;(command "_.pasteclip" "0,0,0" "")
;;(command "zoom" "extents")

)

 

 

Link to comment
Share on other sites

You don't need to turn off layers (sssetfirst nil (ssget "_x" '((62 . 6)(8 . "F_CABLE_AERIAL")))

 

The problem you have is that once you open a new dwg the lisp will cease.

 

The simplest is to use a script something like this. Note blank lines = (command "") etc


(sssetfirst nil (ssget "_x" '((62 . 6)(8 . "F_CABLE_AERIAL")))

 

_.copyclip Previous

 

new" "C:\\Users\\f\\appdata\\local\\autodesk\\autocad 2014\\r19.1\\enu\\template\\acad.dwt

_.pasteclip

"0,0,0"

 

zoom extents

 

 

 

 

 

 

 

Link to comment
Share on other sites

On 9/29/2019 at 1:54 PM, rlx said:

 


***MENUGROUP=RlxMnu

***TOOLBARS
**RLX-TB1
               [_Toolbar("RLX-TB1", _Bottom, _Show, 0, 0, 1)]
ID_Bcopy       [_Button("Copy With Basepoint 0,0", "bcopy.bmp", "ICON_16_BLANK")]^C^C_copybase;0,0;
ID_Bpaste      [_Button("Paste with Basepoint 0,0", "bpaste.bmp", "ICON_16_BLANK")]^C^C_pasteclip;0,0;
ID_GetBcopy    [_Button("Copy With Get Basepoint", "bcopy_get.bmp", "ICON_16_BLANK")]^C^C_copybase;
ID_GetBpaste   [_Button("Paste with Get Basepoint", "bpaste_get.bmp", "ICON_16_BLANK")]^C^C_pasteclip;

***HELPSTRINGS
ID_BCOPY       [Copy with Basepoint 0,0]
ID_BPASTE      [Paste with basepoint 0,0]
ID_GetBCOPY    [Copy with Get Basepoint]
ID_GetBPASTE   [Paste with Get basepoint]

 

A question out of the topic 

How did you extract this list?

 

Link to comment
Share on other sites

I just did cut/copy/past from my RlxMnu.mns file. You may have a different menu file or toolbar. It's just meant for illustration. You can paste/add the macro's to your own buttons in your own menu or toolbar. So you can add :

^C^C_copybase;0,0;

or

^C^C_copybase

to your own buttons. Just use the help function from autocad how to create your own buttons and bitmap icons.

Link to comment
Share on other sites

Wouldn't "Copy with Basepoint 0,0" from one drawing and "Paste with basepoint 0,0" do the same as Ctrl+C and PASTEORIG both of which have icons already?  I do use a "Copy with Basepoint 0,0" in a Copy Drop-down above a Paste Drop-down on a Custom Ribbon Panel. I also added a "Paste as Group" to the 5 Paste options installed with AutoCAD and use RCDATA_16_NEWGROUP as the image for it.  This is the macro for it: ^C^C_pasteblock;\(setq LstBlk(vla-get-Name (vlax-ename->vla-object (entlast))));_explode;_last;_-group;_create;*;;_previous;;(command "-purge" "B" LstBlk "N")
(setq LstBlk nil)

 

To create PNG icons with transparent backgrounds used in all the more recent versions of AutoCAD draw them to fill a square shape in AutoCAD and use PNGOUT.  You will still need to make the background transparent.  Both https://www110.lunapic.com/editor/ & https://www.online-image-editor.com/ are free and do this nicely.

 

I've been using a really cool tool created by BlackBox since February that automatically creates PNG icons with transparent backgrounds and places them in the Custom Icon Location defined in Options.  He hasn't added it to the App Store yet, but here's the link to my Wish in case anyone would like to ask him to put it up there.  https://forums.augi.com/showthread.php?172533-PNGOUT-with-transparent-background-option&p=1340710#post1340710  He may not think anyone else is interested.

Link to comment
Share on other sites

There are often more than one way to do things. I still use my mns files because they are simple and small txt files and easy to modify or extend but I wouldn't be surprised they will become obsolete.  But then again , one day I'll become obsolete myself haha. Usually first thing I do with a new AutoCAD installation is hiding the Ribbon and most of my colleagues to the same. We like our buttons just the way they are , small and always on the same location. Creating icons is indeed very crude but then its not something I do every day. Anyways thanx for the extra info , will have a look at your suggestions but right now I'm in the middle of a very big turnaround so playtime is limited as is access to some sites.

 

:beer:

 

 

Link to comment
Share on other sites

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...