Author Topic: Help on turning off specific xref layer  (Read 6154 times)

0 Members and 1 Guest are viewing this topic.

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Help on turning off specific xref layer
« on: December 06, 2012, 03:52:47 PM »
Hello,
I need help on creating a routine that will allowed me to turn ON or Off a specific layer on a bunch of drawings.
The point is for not to open every single drawing and turn the layer off manually.
Any help will be appreciate it...

Thank you...

BlackBox

  • King Gator
  • Posts: 3770
Re: Help on turning off specific xref layer
« Reply #1 on: December 06, 2012, 04:52:29 PM »
You'll want to iterate a list of valid Drawings using ObjectDBX, then within each DBXDocument Object, iterate the Layers Collection, checking for matching Layer Names, if a valid match, then toggle that Layer Object's LayerOn Property accordingly.
"How we think determines what we do, and what we do determines what we get."

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: Help on turning off specific xref layer
« Reply #2 on: December 06, 2012, 05:13:56 PM »
Hi RenderMan,
That is exactly what I am lookng for, however, I am very familiar with LISP.
I am looking for help on creating one from scratch if I can get some help...

BlackBox

  • King Gator
  • Posts: 3770
Re: Help on turning off specific xref layer
« Reply #3 on: December 06, 2012, 05:35:51 PM »
Hi RenderMan,
That is exactly what I am lookng for, however, I am very familiar with LISP.
I am looking for help on creating one from scratch if I can get some help...

Any routine involving ObjectDBX (appropriately) requires a bit more effort and error handling than a typical requests for help. I, or someone more knowledgeable than I, will post back as time permits.
"How we think determines what we do, and what we do determines what we get."

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help on turning off specific xref layer
« Reply #4 on: December 06, 2012, 06:12:51 PM »
This function will do all of the ObjectDBX work for you:

http://lee-mac.com/odbxbase.html

Load it and call it with the following program (change the layer name to suit):

Code: [Select]
(defun c:frzlay ( )
    (LM:ODBX
        (function
            (lambda ( doc / lay )
                (if
                    (not
                        (vl-catch-all-error-p
                            (setq lay
                                (vl-catch-all-apply 'vla-item
                                    (list (vla-get-layers doc) "Your-Layer-Here")
                                )
                            )
                        )
                    )
                    (vla-put-layeron lay :vlax-true)
                )
            )
        )
        nil t
    )
    (princ)
)

The above is untested.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help on turning off specific xref layer
« Reply #5 on: December 06, 2012, 08:43:23 PM »
Lee your ObjectDBX helper routine is a real time saver.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help on turning off specific xref layer
« Reply #6 on: December 07, 2012, 05:56:55 AM »
Lee your ObjectDBX helper routine is a real time saver.  8-)

Thanks Alan!  :-)

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Help on turning off specific xref layer
« Reply #7 on: December 07, 2012, 11:20:05 AM »
Lee, I have not been over to your site for some time.  I really, really, really like option to preview the code in HTML.  Very sweet.

And the code looks sweet too.  Filed that in back of my brain for when a future need arises.  ;-)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: Help on turning off specific xref layer
« Reply #8 on: December 07, 2012, 01:06:50 PM »
Thank you Lee Mac for helping me out on the script for “Turning specific layer ON or Off in multiples files without opening them”
It works wonderful, however, I forgot to mentioned that, this specific layer is located on an xreference file, sorry.
Would you be able to help me on this one please?

Thank you…

Joselo…

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help on turning off specific xref layer
« Reply #9 on: December 07, 2012, 04:33:30 PM »
Lee, I have not been over to your site for some time.  I really, really, really like option to preview the code in HTML.  Very sweet.

And the code looks sweet too.  Filed that in back of my brain for when a future need arises.  ;-)

Cheers Krushert! I'm glad you like it 8-)

I hope the program is of use to you :-)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help on turning off specific xref layer
« Reply #10 on: December 07, 2012, 04:36:46 PM »
Thank you Lee Mac for helping me out on the script for “Turning specific layer ON or Off in multiples files without opening them”

You're welcome Joselo  :-)

It works wonderful, however, I forgot to mentioned that, this specific layer is located on an xreference file

Although XRefs are not loaded when interfacing with a drawing using ObjectDBX, the XRef-dependent Layers should still be present in the drawing's Layers Collection, hence, you should be able to use the program for your case and specify the name of your XRef-dependent Layer.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Help on turning off specific xref layer
« Reply #11 on: December 10, 2012, 09:27:07 AM »
This function will do all of the ObjectDBX work for you:

http://lee-mac.com/odbxbase.html

Load it and call it with the following program (change the layer name to suit):

Code: [Select]
(defun c:frzlay ( )
    (LM:ODBX
        (function
            (lambda ( doc / lay )
                (if
                    (not
                        (vl-catch-all-error-p
                            (setq lay
                                (vl-catch-all-apply 'vla-item
                                    (list (vla-get-layers doc) "Your-Layer-Here")
                                )
                            )
                        )
                    )
                    (vla-put-layeron lay :vlax-true)
                )
            )
        )
        nil t
    )
    (princ)
)

The above is untested.

Lee

Is it possible to use the following in place of "your-layer-here"?

(list (vla-get-layers doc) "*AREA*,UT*|*PATT*,UT*|*DIMS*,UT*|*NOTE*,UT*|*SYMB*,UT*|*SHTT*,BL-0*|*SHTT*,*|A-CLNG-HEAD,*|A-DOOR-CODE,*|*-2,*|*-3")
« Last Edit: December 10, 2012, 09:32:59 AM by GDF »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help on turning off specific xref layer
« Reply #12 on: December 10, 2012, 09:34:02 AM »
Is it possible to us the following in place of "your-layer-here"?

(list (vla-get-layers doc) "*AREA*,UT*|*PATT*,UT*|*DIMS*,UT*|*NOTE*,UT*|*SYMB*,UT*|*SHTT*,BL-0*|*SHTT*,*|A-CLNG-HEAD,*|A-DOOR-CODE,*|*-2,*|*-3")

The OP actually posed this question via PM, here was my response:

Quote from: Response to PM from OP
The current function is looking for an exact layer name match, and cannot accept wildcards.
To use wildcards, the code must be changed to:


Code: [Select]
(defun c:frzlay ( )
    (LM:ODBX
        (function
            (lambda ( doc / lay )
                (vlax-for lay (vla-get-layers doc)
                    (if (wcmatch (strcase (vla-get-name lay)) "wildcard-match-here")
                        (vla-put-layeron lay :vlax-true)
                    )
                )
            )
        )
        nil t
    )
    (princ)
)

In future, please reply to the forum thread rather than sending a personal message, as the replies will then benefit the whole forum community.

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: Help on turning off specific xref layer
« Reply #13 on: December 10, 2012, 10:05:49 AM »
Thank you Lee Mac,
This routine is a life saver, that was exactly what we were looking for.

Very well done...
Joselo...

GDF

  • Water Moccasin
  • Posts: 2081
Re: Help on turning off specific xref layer
« Reply #14 on: December 10, 2012, 10:16:14 AM »
Lee

Thanks for your response. I have a more specific question and help needed. I will ask it on your website. I will pay for your services for this help. You can then post the solution here to benefit the forum.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64