Jump to content

how can I turn off one layer in many dwgs?


CadTechJGC184

Recommended Posts

ahhhhhhhhhhhhhh why can"t I added a print screen.... i give up!!

 

here's the xref name and layer: UTILITY BASE/C-ELEC-LIN

Link to comment
Share on other sites

Open all the docs you need to freeze the layer in and use this:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] frzlay [b][color=RED]([/color][/b]lay [b][color=BLUE]/[/color][/b] doc lyr[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Documents[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lyr [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
        [b][color=RED]([/color][/b][b][color=BLUE]vla-put-freeze[/color][/b] lyr [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Link to comment
Share on other sites

ahhhhhhhhhhhhhh why can"t I added a print screen.... i give up!!

 

here's the xref name and layer: UTILITY BASE/C-ELEC-LIN

 

Just hit the print screen button, paste into MS Paint, and save as JPEG, then attach.

Link to comment
Share on other sites

hey Lee Mac,

 

How are you doing? thanks for the suggestions. i will give them both a try.

Link to comment
Share on other sites

Open them all at once.

 

I have just tested it though, and its seems to have a problem if the layer to be frozen is not in the drawing - which is weird because I thought I had accounted for that :huh:

Link to comment
Share on other sites

Are you calling the function correctly?

 

It is a sub-function and should be called as follows:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] frzlay [b][color=RED]([/color][/b]lay [b][color=BLUE]/[/color][/b] doc lyr[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Documents[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lyr [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
        [b][color=RED]([/color][/b][b][color=BLUE]vla-put-freeze[/color][/b] lyr [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])

[/color][/b][color=RED][color=Black](frzlay[/color][/color][b][color=RED][color=Black] "[/color][/color][/b]UTILITY BASE/C-ELEC-LIN")

Link to comment
Share on other sites

what do i type once I have opened all the drawing that i want the layer frz in? Is it a lisp?

Link to comment
Share on other sites

You can make your own LISP to call the sub-function and call it what you like:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] frzlay [b][color=RED]([/color][/b]lay [b][color=BLUE]/[/color][/b] doc lyr[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Documents[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lyr [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-layers[/color][/b] doc[b][color=RED])[/color][/b] lay[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
        [b][color=RED]([/color][/b][b][color=BLUE]vla-put-freeze[/color][/b] lyr [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])

[/color][/b][color=RED][color=Black](defun c:whatever ()[/color]
[/color][color=RED][color=Black]  (frzlay[/color][/color][b][color=RED][color=Black] "[/color][/color][/b]UTILITY BASE/C-ELEC-LIN")
 (princ))

Link to comment
Share on other sites

(defun c:frzlay (lay / doc lyr)

(vlax-for doc (vla-get-Documents

(vlax-get-acad-object))

(and (setq lyr (vla-item (vla-get-layers doc) lay))

(vla-put-freeze lyr :vlax-true)))

(princ))

 

(defun c:whatever ()

(frzlay "UTILITY BASE/C-ELEC-LIN")

(princ))

 

 

is this correct? I'm a little lost.

Link to comment
Share on other sites

The frzlay is a sub-function (no "c:"), and needs to be called with one argument (the layer string), from a main-function (which can be named whatever you like - but not the same as the sub-function).

 

When you save LISPs, the filename can be whatever you like - it doesn't have to be the syntax name.

 

I have been in conversation with RonJonp and he has provided a better way to cope with layers that aren't present:

 

(defun frzlay  (lay / doc lyr)
 (vlax-for doc  (vla-get-documents
                  (vlax-get-acad-object))
   (and (not (vl-catch-all-error-p
               (setq lyr (vl-catch-all-apply 'vla-item
                           (list (vla-get-layers doc) lay)))))
        (vla-put-freeze lyr :vlax-true)))
 (princ))

(defun c:test ()
 (frzlay "UTILITY BASE/C-ELEC-LIN")
 (princ))

Save as filename.lsp, open all drawings and invoke with "test"

Link to comment
Share on other sites

i opened 3 just for a test and I typed frzlay, because that's what I named it c:frzlay not c:test and the layer was still thawed.

Link to comment
Share on other sites

i opened 3 just for a test and I typed frzlay, because that's what I named it c:frzlay not c:test and the layer was still thawed.

 

Also, don't name it the same name as the sub-function :geek:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...