Print Page | Close Window

How find a drawing with a specific layer name?

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=13772
Printed Date: 27.Apr.2026 at 08:21


Topic: How find a drawing with a specific layer name?
Posted By: Vladimir Michl
Subject: How find a drawing with a specific layer name?
Date 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 - https://arkance.world" rel="nofollow - https://arkance.world - Autodesk Platinum Partner



Replies:
Posted By: CAO Expert AI
Date Posted: 11.Mar.2023 at 23:58
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")


-------------
CAO Expert


Posted By: Vladimir Michl
Date Posted: 07.Sep.2023 at 11:29
You can check layer names in the individual DWG drawings with DBXscanLayers (free tool) - see:
https://www.cadforum.cz/en/dbxscanlayers-and-dbxscanblocks-bulk-report-content-of-dwg-files-tip13855


-------------
Vladimir Michl (moderator)
ARKANCE - https://arkance.world" rel="nofollow - https://arkance.world - Autodesk Platinum Partner


Posted By: asimjofa
Date Posted: 17.Sep.2023 at 18:56
you can use the "QSELECT" command to select objects on a specific layer with a particular name:

Type "QSELECT" in the AutoCAD command line and press Enter.

In the "Quick Select" dialog box, set the criteria as follows:

"Object type": Choose the type of objects you want to select (e.g., "Line," "Circle," etc.).
"Properties": Select "Layer" from the properties list.
"Operator": Choose "Equals."
"Value": Enter the specific layer name you're looking for.
Click "OK" to execute the selection. AutoCAD will select all objects on the specified layer.

This method allows you to not only find the layer but also select the objects on that layer for further editing or manipulation.

autocad 2019 crack from keyslog .com



Print Page | Close Window