Author Topic: find drawings containing layer  (Read 6837 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
find drawings containing layer
« on: September 22, 2004, 01:40:15 PM »
on mdubs recommendation i have started a new topic. i am trying to run a script to turn on and make a layer non plot. the problem is i have tons of drawings with this layer that i don't have time to find. how can i search for drawings containing a given layer?

David Bethel

  • Swamp Rat
  • Posts: 656
find drawings containing layer
« Reply #1 on: September 22, 2004, 01:48:25 PM »
I can do via ZTree with just a regular text search on .dwg files.  The layer name needs to be a unquie non-ACAD term.  -David
R12 Dos - A2K

ELOQUINTET

  • Guest
find drawings containing layer
« Reply #2 on: September 22, 2004, 01:50:16 PM »
the layer is called z-barcode

M-dub

  • Guest
find drawings containing layer
« Reply #3 on: September 22, 2004, 02:13:48 PM »
Dan, just out of curiosity, have you tried Discovery?  Search for z-barcode.

ELOQUINTET

  • Guest
find drawings containing layer
« Reply #4 on: September 22, 2004, 02:22:35 PM »
yeah tried nuttin. speakin od discovery mdub i'm messin with it right now. there must be a way to open the autocad drawing from the preview screen but i can't seem to get it. i would get a dialogue box but then i unchecked always ask so now when i try to open it just keeps repeating a file download box and i have to completly close out explorer. tried several ways but no go

M-dub

  • Guest
find drawings containing layer
« Reply #5 on: September 22, 2004, 02:27:43 PM »
Well, those will be hyperlinks to the dwf files that Discovery creates.  That's why I'm trying to find out how to convert hyperlinks to text in the Office Forum.  If we can do that, you could do a search for whatever it is, have it display the list instead of the previews, copy it into Excel and modify it into a script....if you wanted to, but at the very least, you could get your list that way......

M-dub

  • Guest
find drawings containing layer
« Reply #6 on: September 22, 2004, 02:29:19 PM »
It would require some monkeying around with the program and the html to have it open up the actual file in Acad...unfortunately...I tried that long ago...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
find drawings containing layer
« Reply #7 on: September 22, 2004, 02:32:31 PM »
It is really irrelevant if the drawing has the layer or not.

Do this ...

Compile a list of all of the drawings you want to "fix" this problem in (if it exists) ...

Use a simple lisp program to test for the existence of this layer, if it exists, turn it on and set it to not plot.

In your script that processes the drawings, simply run the lisp.

Of course I wouldn't bother with doing that unless you are either..
a) sending these out to be plotted
b) plot from a program other than AutoCAD

what I would do is....

In the acaddoc.lsp (on your computer as well as other users) add this:
Code: [Select]

(if (tblsearch "layer" "z-barcode")
 (command "-layer" "ON" "z-barcode" "Thaw" "z-barcode" "P" "N" "z-barcode")
)


You do not need to make it a function unless you want to and then on EVERY drawing you (or others) open it is done for you. No spending time searching for the drawings to "fix" .... noone has to build and run a script, wait for it to run etc... a simple housecleaning routine.
This will also reset it to not plot if a user changes the layer setting while editing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ELOQUINTET

  • Guest
find drawings containing layer
« Reply #8 on: September 22, 2004, 02:38:31 PM »
good idea keith but if i go mokeyin with others system files they start to shake. maybe some covert ops are in order good advice. it's mostly ok none it's all just part of my idiot proof brainstorming. whose the idiot for not thinking of all the possibilities....shhhh it's me

M-dub

  • Guest
find drawings containing layer
« Reply #9 on: September 22, 2004, 02:49:00 PM »
Keith to the rescue again...:)

ELOQUINTET

  • Guest
find drawings containing layer
« Reply #10 on: September 22, 2004, 03:42:52 PM »
ok did a search and found about 200 possible drawings containing layer. opened them in batches and with a little help the layer appeared and i saved it. so i would consider your idea a success keith thank you very much  :wink:

M-dub

  • Guest
find drawings containing layer
« Reply #11 on: September 22, 2004, 03:43:57 PM »
:oops:

ELOQUINTET

  • Guest
find drawings containing layer
« Reply #12 on: September 22, 2004, 03:47:32 PM »
see you learn sumpthin new everyday mdub  :wink:

ronjonp

  • Needs a day job
  • Posts: 7526
find drawings containing layer
« Reply #13 on: September 22, 2004, 04:23:35 PM »
You also might want to look at ezscript pro for making the script files. Very easy to use, especially if you want to run a lisp in each drawing.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ELOQUINTET

  • Guest
find drawings containing layer
« Reply #14 on: September 22, 2004, 04:49:08 PM »
ron where you been i was askin about ezscript. downloaded setup ran and nada how does that work?

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
find drawings containing layer
« Reply #15 on: September 22, 2004, 05:47:49 PM »
Quote from: Keith

what I would do is....

In the acaddoc.lsp (on your computer as well as other users) add this:
Code: [Select]

(if (tblsearch "layer" "z-barcode")
 (command "-layer" "ON" "z-barcode" "Thaw" "z-barcode" "P" "N" "z-barcode")
)


According to the help file
Quote from: ACAD HELP

If you use the command function in an acad.lsp, acaddoc.lsp or MNL file, it should be called only from within a defun statement. Use the S::STARTUP function to define commands that need to be issued immediately when you begin a drawing session. The S::STARTUP function is described in S::STARTUP Function—Post-Initialization Execution.

I don't recall the specifics as to why they say this, but I believe it had to do with some commands not behaving properly before Acad has completely initialized.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
find drawings containing layer
« Reply #16 on: September 22, 2004, 06:08:38 PM »
Hmm... never read that before and I have never had a problem ... but the issue is easily resolved by doing the following ...
Code: [Select]

(if (setq lay (tblobjname "layer" "z-barcode"))
  (progn
    (setq laydata (entget lay))
    (setq templay (subst (cons 62 (abs (cdr (assoc 62 laydata)))) (assoc 62 laydata) laydata))
    (setq templay (subst (cons 70 0) (assoc 70 templay) templay))
    (entmod (subst (cons 290 0) (assoc 290 templay) templay))
  )
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ronjonp

  • Needs a day job
  • Posts: 7526
find drawings containing layer
« Reply #17 on: September 22, 2004, 08:10:12 PM »
Keith,

Code: [Select]
(if (tblsearch "layer" "z-barcode")
 (command "-layer" "ON" "z-barcode" "Thaw" "z-barcode" "P" "N" "z-barcode")
)


How do you make this return a prompt to the command line that layer does not exist?

want something like:

Code: [Select]
(if (tblsearch "layer" "z-barcode")
  (then
    (command "-layer"  "ON"       "z-barcode"  "Thaw"
    "z-barcode"  "P"       "N"    "z-barcode"
   )
    (else
      (prompt "Layer does not exist")
    )
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

sinc

  • Guest
find drawings containing layer
« Reply #18 on: September 22, 2004, 09:07:16 PM »
The "command" function works by running Autocad commands in the current drawing session.  The acad.lsp and acaddoc.lsp routines are run BEFORE the Autocad drawing session is initialized, so there is no Autocad session to run the Autocad command in.  Therefore, "command" won't work.

When the drawing session finishes initializing, the first thing it does is run the "S::STARTUP" function.  Therefore, if you want to do something at startup that uses the "command" function, you need to add it to this function.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
find drawings containing layer
« Reply #19 on: September 22, 2004, 09:13:32 PM »
You re soooo... close ....

Code: [Select]
(if (tblsearch "layer" "z-barcode")
    (command "-layer" "ON" "z-barcode" "Thaw" "z-barcode" "P" "N" "z-barcode" "")
    (prompt "Layer does not exist")
)


Using the second version without the command call...

Code: [Select]
(if (setq lay (tblobjname "layer" "z-barcode"))
  (progn
    (setq laydata (entget lay))
    (setq templay (subst (cons 62 (abs (cdr (assoc 62 laydata)))) (assoc 62 laydata) laydata))
    (setq templay (subst (cons 70 0) (assoc 70 templay) templay))
    (entmod (subst (cons 290 0) (assoc 290 templay) templay))
  )
  (prompt "Layer does not exist")
)



VLisp version ...

Code: [Select]
(setq *acad* (vlax-get-acad-object)
      *doc* (vla-get-activedocument *acad*)
      *layers* (vla-get-layers *doc*)
      found nil
)
(vlax-for *layer* *layers*
  (if (= (vla-get-Name *layer*) "0")
    (progn
      (vla-put-layeron *layer* :vlax-true)
      (vla-put-freeze *layer* :vlax-false)
      (vla-put-Lock *layer* :vlax-false)
      (vla-put-plottable *layer* :vlax-false)
      (setq found T)
    )
  )
)
(if (not found)
  (prompt "Layer does not exist")
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
find drawings containing layer
« Reply #20 on: September 22, 2004, 09:39:20 PM »
Quote from: sinc
The "command" function works by running Autocad commands in the current drawing session.  The acad.lsp and acaddoc.lsp routines are run BEFORE the Autocad drawing session is initialized, so there is no Autocad session to run the Autocad command in.  Therefore, "command" won't work.

When the drawing session finishes initializing, the first thing it does is run the "S::STARTUP" function.  Therefore, if you want to do something at startup that uses the "command" function, you need to add it to this function.


I tested the above scenario on A2k4 ... the results are:

Quote from: AutoCAD 2004 Command Line
Regenerating model.

AutoCAD Express Tools Copyright © 2002-2003 Autodesk, Inc.

ACAD2004.LSP loaded
ACAD2004DOC.LSP loaded
ACADDOC.LSP loaded
-layer
Current layer:  "0"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
ON
Enter name list of layer(s) to turn on: 0 Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Thaw
Enter name list of layer(s) to thaw: 0 Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
P
Enter a plotting preference [Plot/No plot] <Plot>: N
Enter layer name(s) for this plot preference <0>: 0 Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
AutoCAD menu utilities loaded.
ACAD.LSP loaded


Note the order in which the files are loaded .....

AutoCAD Express Tools
ACAD2004.LSP
ACAD2004DOC.LSP
ACADDOC.LSP
ACAD.MNL
ACAD.LSP

Also note that the command called in ACADDOC.LSP executed without fault and also note that modelspace was regenerated before any of these modules loaded. To me that indicates a readiness to accept commands.

As I said... I have used that scenario for many years, probably since R10, of course we only used ACAD.LSP until R14, but I have experienced no negative problems.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ronjonp

  • Needs a day job
  • Posts: 7526
find drawings containing layer
« Reply #21 on: September 23, 2004, 10:27:07 AM »
Thanks Keith  :D . I wish I could learn this stuff. I spent about 45 minutes yesterday trying different variations :?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC