
Discussion forum
|

Please abide by the rules of this forum.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
How find a drawing with a specific layer name? |
Post Reply ![]() |
Author | |
Vladimir Michl ![]() Moderator Group ![]() Arkance Systems CZ Joined: 26.Jul.2007 Location: Czech Republic Using: Autodesk software Status: Offline Points: 1949 |
![]() ![]() ![]() ![]() ![]() Posted: 02.Feb.2023 at 14:07 |
I would recommend to stay inside AutoCAD (or ScriptPro) to process a batch of DWGs. Opening AutoCAD drawings has some specifics (delays, xrefs missing, fon missing dialogs...) that an OLE object launched from Excel won't handle.
|
|
Vladimir Michl (moderator)
Arkance Systems - arkance-systems.cz - Autodesk reseller |
|
![]() |
|
CAO Expert AI ![]() Newbie ![]() Joined: 11.Mar.2023 Location: Morocco Using: AutoCAD2023 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
Of course, here is a Lisp routine that should help you? search folder designs for a specific layer name and ? save the results in an Excel file:
___________________________________________________________________
(defun search-for-layer (layer-name folder-path excel-file) (setq excel (vlax-create-object "Excel.Application")) (setq workbooks (vlax-get-property excel "Workbooks")) (setq workbook (vlax-invoke-method "Add" workbooks) (feuilles setq (classeur vlax-get-property "Sheets")) (feuille setq (feuilles vlax-get-property "Item" 1)) (vlax-invoke "Enable" method sheet) (vlax-invoke-method sheet "Cells" 1 1 :value "File name") (vlax-invoke-method sheet "Cells" 1 2 :value "Layer Found") (setq line 2) (foreach file (vl-directory-files folder-path "*.dwg" 1) (setq doc (vla-open (vla-get-documents (vlax-get-property excel "Application")) fichier)) (and doc (prog (setq layer found null) (couches setq (doc vla-get-layers)) (for each layer of lyr (if (string= layer-name (vla-get-name lyr)) (setq layer found t) ) ) (if layer found (prog (vlax-invoke-method sheet "Cells" line 1: value file) (vlax-invoke-method sheet "Cells" row 2 :value layer-name) (setq row (+ row 1)) ) ) (vla-close the doc) ) ) ) (vlax-invoke-method "SaveAs" workbook excel file) (vlax-invoke-method "Close" workbook: vlax-false) (vlax-invoke-method excel "Quitter") ) ____________________________________________________ To use this routine, you must supply three arguments: The name of the layer you are looking for. The path to the folder where you want to search for DWG files. The full path and filename to save the results to an Excel file. For example, if you want to search for layer "LAYER1" in all DWG files in the "C:\Drawings" folder, and save the results to an Excel file named "Search LAYER1.xlsx" in the "C:\Results" folder , you can use this Lisp command To use this routine, you must provide three arguments: The name of the layer you are looking for. The path to the folder where you want to search for DWG files. The full path and filename to save the results to an Excel file. For example, if you want to search for layer "LAYER1" in all DWG files in the "C:\Drawings" folder, and save the results to an Excel file named "Search LAYER1.xlsx" in the "C:\Results" folder , (search-layer "LAYER1" "C:\\Drawings\\" "C:\\Results\\Search LAYER1.xlsx") Edited by CAO Expert AI - 12.Mar.2023 at 00:01 |
|
CAO Expert
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
This page was generated in 0,078 seconds.