Jonathan Handojo Posted March 18, 2020 Posted March 18, 2020 Hi guys, How do you do an ssget X from another drawing and copying all those into the current drawing? Notes: There's only one layer in there and it's unlocked Only lines are present in that drawing. The reference point to be copied is the same and does not need to be altered. So it's a pretty simple drawing where I just want to copy those lines from the drawing. Thanks, Jonathan Handojo Quote
Stefan BMR Posted March 18, 2020 Posted March 18, 2020 (edited) What is wrong with Copy/Paste to original coordinates? Or Copy with base point/Paste Edited March 18, 2020 by Stefan BMR Quote
Jonathan Handojo Posted March 18, 2020 Author Posted March 18, 2020 Because there are so many other drawings instead of just one. Quote
Stefan BMR Posted March 18, 2020 Posted March 18, 2020 Try this. It doesn't account for any reference point, if the position is not correct you might need to move the objects. (defun c:cpl ( / acobj acdoc model docs dbx acver file path doc l) (setq acobj (vlax-get-acad-object) acdoc (vla-get-activedocument acobj) model (vla-get-modelspace acdoc) docs (vla-get-documents acobj) ) (setq dbx (vla-GetInterfaceObject acobj (if (< (setq acver (atoi (getvar "ACADVER"))) 16) "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa acver)) ) ) ) ;;; (setq reference_point (vlax-3d-point 0.0 0.0 0.0)) (while ;;; (and (progn (princ) (setq file (getfiled "Select file to import lines" (cond (path) ((getvar 'dwgprefix))) "dwg" 2)) ) ;;; (setq insertion_point (getpoint "\nSpecify insertion point: ")) ;;; (setq insertion_point (vlax-3d-point insertion_point)) ;;; ) (setq path (strcat (vl-filename-directory file) "\\") doc nil l nil ) (vlax-for x docs (if (eq (vla-get-fullname x) file) (setq doc x) ) ) (or doc (vla-open dbx file :vlax-true)) (vlax-for obj (vla-get-modelspace (cond (doc) (dbx))) (if (eq (vla-get-objectname obj) "AcDbLine") (setq l (cons obj l)) ) ) (if l ;;; (foreach x (vlax-invoke (cond (doc) (dbx)) 'copyobjects l model) ;;; (vla-move x reference_point insertion_point) ;;; ) ) (princ (strcat "\n" (itoa (length l)) " lines imported from " (strcase (vl-filename-base file)))) ) (vlax-release-object dbx) (princ) ) Quote
Jonathan Handojo Posted March 18, 2020 Author Posted March 18, 2020 1 hour ago, Stefan BMR said: Try this. It doesn't account for any reference point, if the position is not correct you might need to move the objects. (defun c:cpl ( / acobj acdoc model docs dbx acver file path doc l) (setq acobj (vlax-get-acad-object) acdoc (vla-get-activedocument acobj) model (vla-get-modelspace acdoc) docs (vla-get-documents acobj) ) (setq dbx (vla-GetInterfaceObject acobj (if (< (setq acver (atoi (getvar "ACADVER"))) 16) "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa acver)) ) ) ) ;;; (setq reference_point (vlax-3d-point 0.0 0.0 0.0)) (while ;;; (and (progn (princ) (setq file (getfiled "Select file to import lines" (cond (path) ((getvar 'dwgprefix))) "dwg" 2)) ) ;;; (setq insertion_point (getpoint "\nSpecify insertion point: ")) ;;; (setq insertion_point (vlax-3d-point insertion_point)) ;;; ) (setq path (strcat (vl-filename-directory file) "\\") doc nil l nil ) (vlax-for x docs (if (eq (vla-get-fullname x) file) (setq doc x) ) ) (or doc (vla-open dbx file :vlax-true)) (vlax-for obj (vla-get-modelspace (cond (doc) (dbx))) (if (eq (vla-get-objectname obj) "AcDbLine") (setq l (cons obj l)) ) ) (if l ;;; (foreach x (vlax-invoke (cond (doc) (dbx)) 'copyobjects l model) ;;; (vla-move x reference_point insertion_point) ;;; ) ) (princ (strcat "\n" (itoa (length l)) " lines imported from " (strcase (vl-filename-base file)))) ) (vlax-release-object dbx) (princ) ) Wow! It actually works! I'll have to study this code in detail. I was thinking so hard how to get objects from the other drawing. Nice one! The points works as expected. It's exactly where I want the lines to go. I'll just replace the while loop with foreach and a list of filenames to go with. Thanks a bunch man! Quote
CAD_Noob Posted March 18, 2020 Posted March 18, 2020 have you check Leemac's Copy To Drawing? http://www.lee-mac.com/copytodrawing.html Quote This program enables the user to copy a selection of objects to a selected set of drawings, without opening the drawings in the AutoCAD Editor. Quote
Jonathan Handojo Posted March 18, 2020 Author Posted March 18, 2020 1 minute ago, CAD_Noob said: have you check Leemac's Copy To Drawing? http://www.lee-mac.com/copytodrawing.html Yes, I did. That copies object FROM the current drawing instead of TO the current drawing. Quote
CAD_Noob Posted March 18, 2020 Posted March 18, 2020 2 minutes ago, Jonathan Handojo said: Yes, I did. That copies object FROM the current drawing instead of TO the current drawing. Oh i misread your post sorry... Quote
BIGAL Posted March 18, 2020 Posted March 18, 2020 Insert dwg at 0,0 explode once then purge block other dwg name, not much simpler. 1 Quote
mdbdesign Posted March 18, 2020 Posted March 18, 2020 Then do reverse, open all (or part of its-you said it is a lots) dwgs you need to copy from, select destination dwg in Lee dialog box... Quote
Steven P Posted March 18, 2020 Posted March 18, 2020 17 hours ago, Jonathan Handojo said: Yes, I did. That copies object FROM the current drawing instead of TO the current drawing. OK Try Lee Acs Steal routine: http://www.lee-mac.com/steal.html Quote
Jonathan Handojo Posted March 19, 2020 Author Posted March 19, 2020 7 hours ago, Steven P said: OK Try Lee Acs Steal routine: http://www.lee-mac.com/steal.html Yeah, and as a matter of fact,I use it everyday at work. It imports every dictionary fine on that drawing. I want to copy the entity itself into the drawing (the lines). Stefan solved my enquiry. Quote
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.