CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 1748
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

 

HelpCAD discussion

 
CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate 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.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How find a drawing with a specific layer name?

 Post Reply Post Reply
Author
Vladimir Michl View Drop Down
Moderator Group
Moderator Group

Arkance Systems CZ

Joined: 26.Jul.2007
Location: Czech Republic
Using: Autodesk software
Status: Offline
Points: 2018
Post Options Post Options   Thanks (1) Thanks(1)   Quote Vladimir Michl Quote  Post ReplyReply Direct Link To This Post Topic: How find a drawing with a specific layer name?
    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
Back to Top
CAO Expert AI View Drop Down
Newbie
Newbie


Joined: 11.Mar.2023
Location: Morocco
Using: AutoCAD2023
Status: Offline
Points: 8
Post Options Post Options   Thanks (1) Thanks(1)   Quote CAO Expert AI Quote  Post ReplyReply Direct Link To This Post 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")


Edited by CAO Expert AI - 12.Mar.2023 at 00:01
CAO Expert
Back to Top
Vladimir Michl View Drop Down
Moderator Group
Moderator Group

Arkance Systems CZ

Joined: 26.Jul.2007
Location: Czech Republic
Using: Autodesk software
Status: Offline
Points: 2018
Post Options Post Options   Thanks (0) Thanks(0)   Quote Vladimir Michl Quote  Post ReplyReply Direct Link To This Post 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 Systems - arkance-systems.cz - Autodesk reseller
Back to Top
asimjofa View Drop Down
Newbie
Newbie


Joined: 17.Sep.2023
Location: Pakistan
Using: AutoCAD 2016
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote asimjofa Quote  Post ReplyReply Direct Link To This Post 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
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,352 seconds.