Anggi Lesmana Posted September 19 Share Posted September 19 Hi everyone, I have 2 groups of files. Let's say they are Group A and B. All files in group A are source data. And all files in group B are destination data. Files in group A (1-100.dwg) and B are the same number (1A-100A.dwg). Each quantity is 100. I want all the contents/data objects in group A to enter all data in group B, according to the number sequence. Is there an autolisp or script that can do it without opening the sheet one by one and copying and pasting the objects one by one? Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 19 Share Posted September 19 Hello @Anggi Lesmana, welcome in the forum! People can rarely find a program that match all their expectation. We usually write our Lisp programs to solve specific problems. 9 hours ago, Anggi Lesmana said: Is there an autolisp or script that can do it without opening the sheet one by one and copying and pasting the objects one by one? You mean manually open them, right? Or... maybe for some reason you wish the program to transfer the data from one file to the other without to open them?! Can you upload a pair of A/B drawings, stripped down just to some relevant content? Quote Link to comment Share on other sites More sharing options...
Anggi Lesmana Posted September 20 Author Share Posted September 20 (edited) Thanks @fuccaro for your respon. Quote You mean manually open them, right? Or... maybe for some reason you wish the program to transfer the data from one file to the other without to open them?! Yes, that's right. Sure, I share link here sample files on group A (source) and group B (destination). I just wanna copy content drawing only without I open manually one by one. Link : https://drive.google.com/file/d/1jVUiGvfOEyEh7H80RlerYXoaHJcyaHVY/view?usp=drivesdk Thanks. Edited September 20 by Anggi Lesmana Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 24 Share Posted September 24 Quote I want all the contents/data objects in group A to enter all data in group B I opened some drawings of „group A” and I see 3 rectangles, probable ISO A1 sheet contours. In the corresponding „Group B” drawing there is only one border. Do you wish to copy/paste everything from Drawing A into the Drawing B? If Drawing A has data in the first and in the third rectangle, at what position do you expect to land them in the Drawing B? Respecting the original coordinate from Drawing A? Quote Link to comment Share on other sites More sharing options...
Anggi Lesmana Posted September 24 Author Share Posted September 24 Yes, at inner rectangle in the Drawing Group B with original coordinate from Drawing Group A. Is there autolisp that do them automatically ? Thanks so much to respond and your help. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 24 Share Posted September 24 (defun c:pp() (setq fA (files "A") fB (files "B") pathA (car fA) fA (cdr fA) pathB (car fB) fB (cdr fB)) (setq scr (open (strcat pathA "fuccaro.scr") "w")) (foreach fileNameA fA (setq i -1) (setq fileNameA (substr fileNameA 1 (- (strlen fileNameA) 4))) (while (not find) (setq find (vl-string-search fileNameA (nth (setq i (1+ i)) fB)))) (process (strcat pathA fileNameA) (strcat pathB (nth i fB))) (setq find nil) ) (close scr) (setq scr nil) ) (defun files(x / f1 path) ; returns a folder path and the DWG files within (setq f1 (getfiled (strcat "Select files " x) "" "dwg" 16) path (substr f1 1 (1+ (vl-string-position (ascii "\\") f1 nil T)))) (cons path (vl-directory-files path "*.dwg" 1)) ) (defun process (a b) (princ (strcat a " - " b "\n")) (write-line (strcat "_open " a ".dwg") scr) (write-line (strcat "copybase " "0,0,0 " "all" " ") scr) (write-line (strcat "_close " "y") scr) (write-line (strcat "_open " b) scr) (write-line (strcat "pasteclip " "0,0,0") scr) ;(write-line (strcat "_close " "Y") scr) ) Move the Group A and Group B in separate folders. Open a new drawing and run this Lisp. When it prompts you for "Select files A" click any of the files A (just one of them). Do the same for the files B. The lisp will generate a script file in the directory A (the location of the Files A) named "fuccaro.scr" Drag this file in the drawing area of the current drawing -it should do the rest of the job for you. And some recommendations: Make safety copy of Group B before start Try the program first with only few drawings Even if it works as expected, don't try to process lot of of drawings at a time. Turn off OSNAP Good luck! Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 24 Share Posted September 24 After running a few times the previous program, I think I have a better version: (defun c:pp() (setvar "filedia" 0) (setq fA (files "A") fB (files "B") pathA (car fA) fA (cdr fA) pathB (car fB) fB (cdr fB)) (setq scr (open (strcat pathA "fuccaro.scr") "w")) (if (not (vl-file-directory-p (strcat pathB "newDrawings\\"))) (vl-mkdir (strcat pathB "newDrawings\\"))) (foreach fileNameA fA (setq i -1) (setq fileNameA (substr fileNameA 1 (- (strlen fileNameA) 4))) (while (and (not find) (< i (1- (length fB)))) (setq find (vl-string-search fileNameA (nth (setq i (1+ i)) fB)))) (process (strcat pathA fileNameA) pathB (nth i fB)) (setq find nil) ) (close scr) (setvar "filedia" 1) ) (defun files(x / f1 path) ; returns a folder path and the DWG files within (setq f1 (getfiled (strcat "Select files " x) "" "dwg" 16) path (substr f1 1 (1+ (vl-string-position (ascii "\\") f1 nil T)))) (cons path (vl-directory-files path "*.dwg" 1)) ) (defun process (a pathB b) (princ (strcat a " - " b "\n")) (write-line (strcat "_open " a ".dwg") scr) (write-line (strcat "copybase " "0,0,0 " "all" " ") scr) (write-line (strcat "_close " "y") scr) (write-line (strcat "_open " pathB b) scr) (write-line "zoom e" scr) (write-line (strcat "pasteclip " "0,0,0") scr) (write-line (strcat "saveas 2018 " pathB "newDrawings\\" b) scr) (write-line (strcat "_close") scr) ) Now the program will leave the original files unchanged. The results are saved in FolderB\newDrawings. Quote Link to comment Share on other sites More sharing options...
Anggi Lesmana Posted September 25 Author Share Posted September 25 I apologize @fuccaro, I was in a hurry to uploaded the sample drawing. All drawing files in Group A should contain only one rectangle, not three. I revised them in new link here. And I have tried to call your lisp but it doesn't work even though I have loaded it in appload. Could you please explaint it in a little more detail how to use this lisp ? Ohya, just FYI... I think I don't need the lisp automatically create separate newfiles beside all current drawing files in group B, just copying to each dwg file in group B directly from group A. Maybe you want to revise your lisp before I do. New link : https://drive.google.com/file/d/1GGgYPXf4195a6XWI5shKtjZgLbxiP7LB/view?usp=sharing Thanks fuccaro. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 25 Share Posted September 25 Copy the program text from this forum and paste it in Notepad. Save it as myLisp.lsp on your computer. Open AutoCAD and drag the file icon in the drawing area. AutoCAD should report something like "PP loaded". Type PP in the command line -it should start the program. For each file in the group A must have a pair in the group B -the program will match them by their names. The resulted drawings are saved in a new location for your protection; if the program doesn't work as you expect, the original drawings are left unchanged. That's all the help I can give you today. Have a good day! Quote Link to comment Share on other sites More sharing options...
fuccaro Posted September 30 Share Posted September 30 No progress? I tested it and it works for me... Quote Link to comment Share on other sites More sharing options...
Anggi Lesmana Posted October 1 Author Share Posted October 1 I'm sorry @fuccaro, I'm currently involved in another project that will be finished in 1 or 2 days. Of course I will give you updates on my question in this thread soon. Thank you very much for your attention 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.