Author Topic: How find a AutoCAD drawing with a specific layer name?  (Read 2016 times)

0 Members and 1 Guest are viewing this topic.

CAD_guru

  • Guest
How find a AutoCAD drawing with a specific layer name?
« on: January 31, 2023, 05:43:00 AM »
 :idea:Looking for a solution.
Aa lisp routine to search various folders drawings (.dwg files) to a specific layer name.  The result in an excel list of the found dwg files where the specific layer is located.  For example select folder and even subdirs. Look for given layer name: .... Seach and result, only the drawings that contains layer name .....    I have a lisp routine that will scan in a folder of drawings for all layer names. I want to specify it. It must be in a atnother solution. To specify to search various folders drawings (.dwg files) for a specific layer name. The result in an excel list of the found dwg files where the specific layer is located.  You can read the current code in the topic. And that code works. I would like an extension to the existing module with function as described in the topic.
« Last Edit: January 31, 2023, 09:58:32 AM by CAD_guru »

JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a drawing with a specific layer name?
« Reply #1 on: January 31, 2023, 08:28:42 AM »
Why wouldn't you just use Windows search feature in Windows Explorer (It doesn't give you results in Excel but why do the results have to be in Excel)?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a drawing with a specific layer name?
« Reply #2 on: January 31, 2023, 09:39:21 AM »
What do you mean it's not possible in Windows Explorer?

1. Open File Explorer.
2. Go to File --> Change Folder and search options
3. From the Search tab choose: Always search file and contents...
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org


JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #4 on: January 31, 2023, 11:23:49 AM »
Since when can Windows read in AutoCAD files for a specific layer name?
Tested your suggestion, but it's not working.

With lisp you can use getstring to specify a layer name, acet-ui-pickdir to select a folder, ObjectDBX/vla-get-layer to go inside a drawing database and then write the search results to a csv file.

I started using a computer in Windows XP days but I had one employer that used Windows NT and you could search drawings for Layer names and DText entries even in windows NT but I don't think you can search for dtext strings anymore (Autodesk updated the file format many times since then). -i.e. The fact that windows search will find the items in those files was not because of what Microsoft did; it was because of what Autodesk's dwg file format allowed (kept DTEXT strings as plain text instead of binary in the file format). I know you can search for layer names still because I just tried it (several times).

I know how I would go about solving the problem in programming terms/methods but I'm trying to ask why when/if there is already a (possible) solution for you.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

trogg

  • Bull Frog
  • Posts: 255
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #5 on: January 31, 2023, 11:47:36 AM »
John,
This would be pretty cool to search in windows explore.
Can you please explain how to do so?

I am simply entering in the search bar the layer name at the top-right of the explorer window in a folder and it isn't finding anything even though I know that the layer exists. So I must be doing something wrong.

So if you wouldn't mind, I'd really like to know how.

Thank you,
~Greg

edit: P.S. - The only way that I know how to do this on individual files is to use Design Center...

JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #6 on: January 31, 2023, 12:28:20 PM »
John,
This would be pretty cool to search in windows explore.
Can you please explain how to do so?

I am simply entering in the search bar the layer name at the top-right of the explorer window in a folder and it isn't finding anything even though I know that the layer exists. So I must be doing something wrong.

So if you wouldn't mind, I'd really like to know how.

Thank you,
~Greg

edit: P.S. - The only way that I know how to do this on individual files is to use Design Center...

I posted instructions on how to enable windows to "search file contents" here: https://www.theswamp.org/index.php?topic=58064.msg612987#msg612987

Once you have that you can use wildcards and other stuff. Here is a link to an article on the other features of the windows search tool.
https://www.howtogeek.com/school/learning-windows-search/lesson4/
« Last Edit: January 31, 2023, 12:32:06 PM by JohnK »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

mhupp

  • Bull Frog
  • Posts: 250
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #7 on: January 31, 2023, 01:42:36 PM »
bastards took away the calendar that pops up with date: why IDK.

So you have to type everything out now

date:09/08/2022
or
datemodified:09/08/2022

JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #8 on: January 31, 2023, 01:59:58 PM »
:p So let me get this straight. You put your fingers on the keyboard to type "date:" and then you WANT to grab the mouse and pick a date instead of just typing: "09/08/2022"?! ...The numeric keypad is half the distance. I dislike my mouse (and the feeling seems mutual).

Seriously though, I don't think I have ever searched for a file with a date. Ever. How do you remember dates? My date search would look like this: "date:<today"
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

57gmc

  • Bull Frog
  • Posts: 366
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #9 on: January 31, 2023, 02:10:02 PM »
John, I created a unique layer name in a test dwg and entered the layer name in the search bar but it doesn't find it. Am I missing something?

JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #10 on: January 31, 2023, 02:24:46 PM »
John, I created a unique layer name in a test dwg and entered the layer name in the search bar but it doesn't find it. Am I missing something?

Did you allow Windows search to search the file contents?
1. Open File Explorer.
2. Go to File --> Change Folder and search options
3. In the Search tab choose: Always search file and contents...

FYI: Just before I hit post on this I typed:
1. Windows key + E
2. Used my quick access to go to a project folder (my projects top level folder).
3. Hit <F3>
4. Typed: Defpoints
Windows found/listed drawing files (NOTE I also allow for "All subdirectories" in my searches because I cannot remember where I put things and what I type in my specifications so my searches are typically for spec sections or conditions).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #11 on: January 31, 2023, 02:28:48 PM »
This would be pretty cool to search in windows explore.
won't work
explorer searches for a certain string inside a file, which can be anything - layer, text style, part of a mtext...
remember that stings can also be unicoded

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #12 on: January 31, 2023, 02:33:56 PM »
I dislike my mouse (and the feeling seems mutual).
aren't disliking the mouse and using windows file explorer mutually exclusive? :)

JohnK

  • Administrator
  • Seagull
  • Posts: 10653
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #13 on: January 31, 2023, 02:42:35 PM »
Ugh! I even bought a Windows Brand mouse, last time, hoping my experience would improve (but I guess I should have spent more than $11; what can I expect from a crappy mouse).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

57gmc

  • Bull Frog
  • Posts: 366
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #14 on: January 31, 2023, 04:01:56 PM »
John, I created a unique layer name in a test dwg and entered the layer name in the search bar but it doesn't find it. Am I missing something?

Did you allow Windows search to search the file contents?
1. Open File Explorer.
2. Go to File --> Change Folder and search options
3. In the Search tab choose: Always search file and contents...

FYI: Just before I hit post on this I typed:
1. Windows key + E
2. Used my quick access to go to a project folder (my projects top level folder).
3. Hit <F3>
4. Typed: Defpoints
Windows found/listed drawing files (NOTE I also allow for "All subdirectories" in my searches because I cannot remember where I put things and what I type in my specifications so my searches are typically for spec sections or conditions).

I did that but it didn't work. I moved the file from Downloads (I use that for temp stuff that I clean out later) to another folder and it worked this time. Must be some sort of fluke with the Downloads folder. Good tip John, I learned something new. I've been using Notepad++ to find text in files. But it only searches text-based files. It didn't find the layer in the dwg.

To the OP's question, I could see that using Explorer could lead to false positives if there were other things with the same search criteria, but not a Layer name, e.g. a dim style or block name. From your previous post, it seems like you have the skill to write your code.
« Last Edit: January 31, 2023, 04:14:13 PM by 57gmc »