karfung Posted 5 hours ago Posted 5 hours ago (edited) (defun c:new_desktop_file_copy (/ acad_dbx object_list zero_point) (defun make_color_21 (/ layers) (setq layers (vla-get-layers acad_dbx)) (vlax-map-collection (vla-get-blocks acad_dbx) '(lambda (block) (vlax-map-collection block '(lambda (object) (vla-put-color object 256) (if (/= 21 (vla-get-color (setq layer (vla-item layers (vla-get-layer object))))) (vla-put-color layer 21) ) ) ) ) ) ) (setq acad_dbx (vla-getinterfaceobject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'acadver) 1 2)))) (prompt "\nPick objects to copy to a new file on the desktop...") (setq object_list (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget)))))) (setq zero_point (getpoint "\nPick zero point for the copied entities: ")) (foreach copied_object (setq odbx_objects_list (vlax-invoke (vla-get-database (vla-get-activedocument (vlax-get-acad-object))) 'copyobjects object_list (vla-get-modelspace acad_dbx) ) ) (vla-move copied_object (vlax-3d-point zero_point) (vlax-3d-point 0 0 0)) ) (make_color_21) (vla-saveas acad_dbx (princ (strcat (getenv "userprofile") "\\Desktop\\" (getstring "\nEnter file name: ") ".dwg"))) (vlax-release-object acad_dbx) (princ) ) Hi Bro, The LISP code above is awesome, and it is working. But, I encountered an error below and as per the attached drawing 1 with mp4 video (in link) and added it as follows, 1). Please set the unit to be "mm" in the created file. 2). Please zoom extend for the created file. fyi, I did changed the LISP code to "CP" Kindly advise and revert with the completed Lisp code. Thanks. https://drive.google.com/file/d/15VNesdJ3uHtPbUlrNbCsaP0yMzY3e2Po/view?usp=sharing Drawing1.dwg Edited 2 hours ago by SLW210 Added Code Tags!! Quote
SLW210 Posted 2 hours ago Posted 2 hours ago In the future, please place your code in code tags. (<> in the editor toolbar) Quote
SLW210 Posted 2 hours ago Posted 2 hours ago Your video did not work for me. Your LISP ran just fine on my computer. 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.