Author Topic: Turning off reconciled layers  (Read 2322 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Turning off reconciled layers
« on: March 06, 2020, 08:15:52 AM »
After about 10 years of not using AutoCAD I have a small AutoCAD Job and I could use a little help clearing out the fuzz. Please tell me if I am wrong.

First topic is Reconciled layers. I used to set LAYEREVAL to 0 but now it appears that it has been replaced with LAYERVALCTL? I penned the following code and have it in one of my start up files, is is correct? It seems to work but I don't know if I have the right version numbers or even the right variable(s) for what I want to do -i.e. turn reconciled layers off.

Code - Auto/Visual Lisp: [Select]
  1.   ((> 21 (atoi (getvar 'acadver)))
  2.      ;; AutoCAD 2008 and older
  3.      (setvar 'LAYEREVAL 0)
  4.      (setvar 'LAYERNOTIFY 0))
  5.   ((< 21 (atoi (getvar 'acadver)))
  6.      (setvar 'LAYEREVALCTL 0))
  7.   )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Turning off reconciled layers
« Reply #1 on: March 06, 2020, 08:29:08 AM »
FWIW, rather than relying on AutoCAD version numbers (which then need to be subsequently maintained), I find it is usually easier to test whether a system variable exists by performing a getvar prior to the setvar, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (foreach v '(layereval layernotify layerevalctl)
  2.     (if (getvar v) (setvar v 0))
  3. )


JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Turning off reconciled layers
« Reply #2 on: March 06, 2020, 08:45:44 AM »
Nice. Thank you!

A bit of a sidebar then (trying to de-fuzz my AutoLisp skills too). Wouldn't it be better/same to ignore the getvar portion and just wrap up the setvars in a cond? -i.e. This is obviously a pretty small portion of code so I'm not going after "speed improvements" per se; I'm only trying to remember coding nuances.

Code - Auto/Visual Lisp: [Select]
  1.   ( (setvar 'LAYEREVAL 0) )
  2.   ( (setvar 'LAYERNOTIFY 0) )
  3.   ( (setvar 'LAYEREVALCTL 0) )
  4.   )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Turning off reconciled layers
« Reply #3 on: March 06, 2020, 09:02:00 AM »
On second thought: If the variable doesn't exist the evaluation of the COND statements will fail. Right?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Turning off reconciled layers
« Reply #4 on: March 06, 2020, 11:38:01 AM »
On second thought: If the variable doesn't exist the evaluation of the COND statements will fail. Right?
If that first ( (setvar 'LAYEREVAL 0) ) exists then the subsequent two lines will not get evaluated.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Turning off reconciled layers
« Reply #5 on: March 06, 2020, 11:47:27 AM »
On second thought: If the variable doesn't exist the evaluation of the COND statements will fail. Right?
If that first ( (setvar 'LAYEREVAL 0) ) exists then the subsequent two lines will not get evaluated.

...And that too. Glad I asked, I'm obviously, very rusty. Thanks.

Quote
...until one of these items returns a value other than nil.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Turning off reconciled layers
« Reply #6 on: March 06, 2020, 02:43:27 PM »
On second thought: If the variable doesn't exist the evaluation of the COND statements will fail. Right?

Exactly - setvar with an unknown system variable does not fail gracefully like getvar does, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. _$ (setvar "se7en" 0)
  2. ; error: AutoCAD variable setting rejected: "se7en" 0

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Turning off reconciled layers
« Reply #7 on: March 06, 2020, 03:00:53 PM »
Well, that example just doesn't make any sense whatsoever--that variable should be accepted by most cad programs--but I see that now. ...Thanks. One small (tiny, mostly useless) bit of code, after a while away from AutoLisp, and the frustrations with the language start again. :)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org