Jump to content

Recommended Posts

Posted

Hi all

I would like to be able to:

 

1. Copy all elements in drawing

2. Create new drawing

3. Paste elements into new drawing

 

Following is what I have so far - but it trips after the _.new command

 

filedia
0
_copybase
0,0
all

_.new
C:\AUTOCAD2010\TEMPLATES\TEST.DWT


_pasteclip
0,0

filedia
1

 

I would like to achieve this as a script. Is anyone able to offer any pointers?

 

Thanks

Paul

Posted

Use

C:\\AUTOCAD2010\\..

or

C:/AUTOCAD2010/...

 

Once you open another drawing the script will stop and not continue in that new drawing.

Posted

Thanks RKENT - I tried them both but it still gets stuck at the same point.

 

The template file is the default. Even if I could get the routine to ENTER to accept the default. That's why I entered twice in the code under the template name.

Posted

Actually to explain a bit more...it doesn't need to specifically be that template file. I just want to create a new file to paste the objects into.

Posted

I don't think it will work with a script. The instant you hit enter for the .new command you are no longer in that drawing and so the script is no longer valid

Posted

If you want to copy all objects, you can use wblock instead of copy-paste

-wblock "D:/Temp/test.dwg" *
open "D:/Temp/test.dwg" 

But you can only create dwg files, not dwt

Posted (edited)

This script works for me...

 

(vl-load-com)
(setq fn (open "c:/doc.txt" "w"))
(setq k -1)
(while (not (equal (vla-get-activedocument (vlax-get-acad-object)) (vla-item (vla-get-documents (vlax-get-acad-object)) (setq k (1+ k))))))
(princ k fn)
(close fn)
(setq fn nil k nil)
filedia
0
_.copybase
0,0
all

filedia
1
_.new

_.pasteclip
0,0
(vl-load-com)
(setq fn (open "c:/doc.txt" "r"))
(setq k (read (read-line fn)))
(close fn)
(vla-activate (vla-item (vla-get-documents (vlax-get-acad-object)) k))
(defun doc nil
(if (findfile "c:\\doc.txt") (vl-file-delete "c:\\doc.txt"))
(setq doc nil fn nil k nil)
(princ)
)
(alert "Type (doc) at command prompt")
(princ)

HTH, M.R.

P.S. Make sure your root c:\ is write-read enabled...

Edited by marko_ribar
Posted

Thanks Stefan. Great idea - I'll try that.

 

Thanks Marko. Looks great but gets stuck asking for user input to select a template. I was logged in as administrator with read/write on C drive.

Posted

Whats wrong with old fashioned new -INSERT filename etc explode purge blockname. You have contradicted yourself by saying pick objects yet your script uses All.

Posted (edited)

That's true BigAl, I did contradict myself. Probably didn't give enough information. I'll explain the full story...

 

1. I've got a bunch of dirty drawings with a title block with attributed data that I want to run a Data Extraction (DE) on.

 

2. The DE won't work as drawings are dirty. I've run a script to remove all the xrefs so now have just the title block and other stuff in paperspace.

 

3. I want to copy the title block data (doesn't really matter if the rest of the paper space stuff comes too) and paste into a new clean drawing.

 

4. Then I can run the DE

 

So I've been exploring the wblock option and this is what I have...

 

For the naming I'm hoping to extract the existing drawing name (with the dwgname part of the code) and append a -NEW at the end. Then save to the location listed...but it's not working yet.

 

filedia
0
tilemode
0
(setq dwgname (getvar "DWGNAME"))
-wblock
C:\Users\Paul&Jen\Documents\_Clients\HELLO\Contract\_ABCD\WORKING\SHEETS\SS\140918_PAUL_CreateCleanDrawing\

filedia
1

Edited by pixel8er
Posted

You may be better to write as lisp basicly same as you have just watch the directory pathing you need to use // or \\ I think script is opposite.

 

have a look at WWW.Lee-mac.com I think Steal.lsp

Posted

I know Lee's stuff well. Have used quite a few of his programs - always work very well. I've looked at the steal program before but I don't think it will work for what I want to do.

Posted

Thanks for the replies everyone.

 

I couldn't get it to work and time was running out so I went through the drawings and worked out that only about 10% (30ish) of the drawings were dirty. So manually copied the data into a new clean drawing.

 

Couple of hours boring work but all done now. The Data Extraction worked so very happy now!

 

Paul

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