pixel8er Posted September 17, 2014 Share Posted September 17, 2014 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 Quote Link to comment Share on other sites More sharing options...
rkent Posted September 17, 2014 Share Posted September 17, 2014 Use C:\\AUTOCAD2010\\.. or C:/AUTOCAD2010/... Once you open another drawing the script will stop and not continue in that new drawing. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted September 17, 2014 Author Share Posted September 17, 2014 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. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted September 17, 2014 Author Share Posted September 17, 2014 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. Quote Link to comment Share on other sites More sharing options...
rkent Posted September 17, 2014 Share Posted September 17, 2014 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 Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted September 17, 2014 Share Posted September 17, 2014 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 Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 17, 2014 Share Posted September 17, 2014 (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 November 20, 2014 by marko_ribar Quote Link to comment Share on other sites More sharing options...
pixel8er Posted September 17, 2014 Author Share Posted September 17, 2014 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 18, 2014 Share Posted September 18, 2014 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. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted September 18, 2014 Author Share Posted September 18, 2014 (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 September 18, 2014 by pixel8er Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 18, 2014 Share Posted September 18, 2014 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 Quote Link to comment Share on other sites More sharing options...
pixel8er Posted September 18, 2014 Author Share Posted September 18, 2014 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. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted September 18, 2014 Author Share Posted September 18, 2014 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.