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

0 Members and 1 Guest are viewing this topic.

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: Help on turning off specific xref layer
« Reply #15 on: December 10, 2012, 11:02:19 AM »
Lee Mac,
This routine works great and does what we were looking for, however, the wildcard was there due that is an old code for a layer on an xref file, and this wildcard can be omitted.
My intension here is not to only be hard coded a specific layer name, meaning if we can use this routine to turn other layers on as well  by just changing the layer’s name.
My initial idea was to turn on a specific layer, perhaps our Engineer name on and off with the same routine, so we can just turn on one engineer name and turn another engineer off.

Example: Marc’s is on one layer and it is use for specific project, so I want to turn Marc’s layer on in a bunch of drawing.
Jess is another engineer name in the same xref file, when Marc’s name is no longer needed for this project, I would like to turn Marc’s layer off and turn Jess layer on, can this be done with the same routine?

Thank you…

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help on turning off specific xref layer
« Reply #16 on: December 10, 2012, 11:14:40 AM »
...can this be done with the same routine?

Yes, most things are possible - though, with more time and modifications...

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: Help on turning off specific xref layer
« Reply #17 on: December 10, 2012, 02:25:55 PM »
Thank you Lee for your help, I really appreciated it.

Lee,

On your routine, when I change to a different xref layer name, perhaps from "*|ManU_NAME") to "*|WestHam_NAME"), the routine doesn’t recognized that layer.
I have no issue running the routine with "*|ManU_NAME"), would it be nice to just to be able to change layer name and run the routine.
Any idea why isn’t working that way?

 (defun c:frzlay ( )
    (LM:ODBX
        (function
            (lambda ( doc / lay )
                (vlax-for lay (vla-get-layers doc)
                    (if (wcmatch (strcase (vla-get-name lay)) "*|your_layer_name_here")
                        (vla-put-layeron lay :vlax-true)
                    )
                )
            )
        )
        nil t
    )
    (princ)
)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Help on turning off specific xref layer
« Reply #18 on: December 10, 2012, 02:55:07 PM »
Make your search pattern all uppercase.

(wcmatch (strcase (vla-get-name lay)) "*|YOURLAYERNAMEHERE")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

diego65

  • Newt
  • Posts: 51
  • Learning LISP is a cool thing
Re: Help on turning off specific xref layer
« Reply #19 on: December 10, 2012, 04:04:34 PM »
Hi ron,

Thank you for your help.
I have already asked Lee, maybe you can help me...

My intension here is not to only be hard coded a specific layer name, meaning if we can use this routine to turn other layers on as well  by just changing the layer’s name.
My initial idea was to turn on a specific layer, perhaps our Engineer name on and off with the same routine, so we can just turn on one engineer name and turn another engineer off.

Example: Marc’s is on one layer and it is use for specific project, so I want to turn Marc’s layer on in a bunch of drawing.
Jess is another engineer name in the same xref file, when Marc’s name is no longer needed for this project, I would like to turn Marc’s layer off and turn Jess layer on, can this be done with the same routine?

Thank you…

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Help on turning off specific xref layer
« Reply #20 on: December 10, 2012, 04:17:11 PM »
Just look for the other layer name and turn it off ... something like so:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:frzlay ()
  2.   (lm:odbx
  3.     (function (lambda (doc / lay)
  4.                 (vlax-for lay (vla-get-layers doc)
  5.                   (if (wcmatch (strcase (vla-get-name lay)) (strcase "*MARC*"))
  6.                     ;; Turn the layer on
  7.                     (vla-put-layeron lay :vlax-true)
  8.                   )
  9.                   (if (wcmatch (strcase (vla-get-name lay)) (strcase "*JESSE*"))
  10.                     ;; Turn the layer off
  11.                     (vla-put-layeron lay :vlax-false)
  12.                   )
  13.                 )
  14.               )
  15.     )
  16.     nil
  17.     t
  18.   )
  19.   (princ)
  20. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC