Author Topic: How find a AutoCAD drawing with a specific layer name?  (Read 1997 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: 10652
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: 10652
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: 10652
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: 10652
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: 10652
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: 10652
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: 10652
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 »

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #15 on: February 01, 2023, 08:29:50 AM »

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #16 on: February 01, 2023, 09:11:28 AM »
Also posted here:
https://stackoverflow.com/q/75299071/7531598
CAD_guru, posting in several/multiple locations like this is a bit disrespectful.
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 #17 on: February 01, 2023, 09:57:08 AM »
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"

You have had the good fortune of not having to work with people that are/were computer illiterate. It was once or twice a week I would have to go hunting for files that they swear they saved to folder x location. usually it was saved in the project folder they were previously working on. searching by modify date saved my life or at least several hours of work every week. Working in cad for almost 2 decides my default position is one hand on the keyboard one on the mouse. So all I had to do was type date and then the calendar would pop up & one mouse click later the files. But MS took it out for some reason about 3 or 4 years ago.

The pop up calendar *chef's kiss* may you rest in peace.
« Last Edit: February 01, 2023, 10:02:56 AM by mhupp »

BIGAL

  • Swamp Rat
  • Posts: 1420
  • 40 + years of using Autocad
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #18 on: February 01, 2023, 06:09:25 PM »
Mhupp get a copy of "Everything" it is fantastic it indexes multiple drives, type in a file name or part of and instant here it is. Great on a server or local drive.

A man who never made a mistake never made anything

57gmc

  • Bull Frog
  • Posts: 366
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #19 on: February 01, 2023, 06:57:00 PM »
Is this what you're talking about Al?https://www.voidtools.com/
It was interesting googling everything.  :2funny:

I also found this at https://www.pcmag.com/reviews/everything
There are two things that differentiate Everything from Lookeen and X1 Search. First, the other two programs index and search email, as well as documents. Second, they both index the full text of each item, so you can search for any text in the file or email. Everything limits the index and the search to file names and paths only.

Lookeen might be a better solution if you need to do a full-text search.
« Last Edit: February 01, 2023, 07:14:32 PM by 57gmc »

mhupp

  • Bull Frog
  • Posts: 250
Re: How find a AutoCAD drawing with a specific layer name?
« Reply #20 on: February 01, 2023, 08:26:25 PM »
I'll look into it BIGAL. Currently right now in using a spreadsheet that has the output from command prompt

dir /b /s *.dwg *.dxf > list.txt

This will generate a text file that has the full path of the files found. Input that into a spread sheet and you can search over thousands folders in seconds with xlookup.
you have to update the list if you want to keep it current so it isn't in real time. But this is the fastest method I have found to search the whole drive.