Author Topic: How to freeze a list of layers?  (Read 6074 times)

0 Members and 1 Guest are viewing this topic.

scottcd

  • Newt
  • Posts: 52
How to freeze a list of layers?
« on: September 30, 2008, 08:02:50 AM »
I have the following list of layers (filtered_layerlist)

("G8010001" "G8010004" "G8010010" "G8010015" "G8010021" "G8010026" "G8010027"
"G8010030" "G8010032" "G8010035" "G8010036" "G8010052" "G8010057" "G8010059"
"G8010071" "G8010072" "G8010098" "G8010321" "G8010374" "G8010376" "G8010382"
"G8010388" "G8010397" "G8010400" "G8010570" "G8010572" "G8011000" "G8011005"
"G8011006" "G8011009" "G8011010")

     I was trying to use the following to freeze all the layers in the above list

 (mapcar '(lambda (x) (command "layer" "freeze" x "") filtered_layerlist))

But I know the syntax is not correct for a start - can anyone give me a push in the right direction.

Cheers

Scott



AutoCAD Dos R9 - 2018 and BricCAD 18.2

kpblc

  • Bull Frog
  • Posts: 396
Re: How to freeze a list of layers?
« Reply #1 on: September 30, 2008, 08:26:58 AM »
Code: [Select]
(setq layers '("G8010001"      "G8010004"      "G8010010"      "G8010015"
               "G8010021"      "G8010026"      "G8010027"      "G8010030"
               "G8010032"      "G8010035"      "G8010036"      "G8010052"
               "G8010057"      "G8010059"      "G8010071"      "G8010072"
               "G8010098"      "G8010321"      "G8010374"      "G8010376"
               "G8010382"      "G8010388"      "G8010397"      "G8010400"
               "G8010570"      "G8010572"      "G8011000"      "G8011005"
               "G8011006"      "G8011009"      "G8011010"
               )
      ) ;_ end of setq

(defun test (lst / adoc)
  (vl-load-com)
  (vla-startundomark
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
    ) ;_ end of vla-StartUndoMark
  (foreach item lst
    (vl-catch-all-apply
      (function
        (lambda ()
          (vla-put-freeze (vla-item (vla-get-layers adoc) item) :vlax-true)
          ) ;_ end of lambda
        ) ;_ end of function
      ) ;_ end of vl-catch-all-apply
    ) ;_ end of foreach
  (vla-endundomark adoc)
  (princ)
  ) ;_ end of defun
Sorry for my English.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to freeze a list of layers?
« Reply #2 on: September 30, 2008, 08:42:54 AM »
If you're going to use the COMMAND, this will do.
Code: [Select]
(defun c:test()
 
(setq lst
       '("G8010001" "G8010004" "G8010010" "G8010015" "G8010021" "G8010026" "G8010027"
"G8010030" "G8010032" "G8010035" "G8010036" "G8010052" "G8010057" "G8010059"
"G8010071" "G8010072" "G8010098" "G8010321" "G8010374" "G8010376" "G8010382"
"G8010388" "G8010397" "G8010400" "G8010570" "G8010572" "G8011000" "G8011005"
"G8011006" "G8011009" "G8011010"))
  (setq str "")
  (mapcar '(lambda(x) (setq str (strcat str x ","))) lst)
  (command "_-layer" "_F" str "")
  (princ)
  )
Another version
Code: [Select]
(command "._Layer")
(mapcar '(lambda (x) (command "_f" x)) laylst)
(command "")
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.

scottcd

  • Newt
  • Posts: 52
Re: How to freeze a list of layers?
« Reply #3 on: September 30, 2008, 08:49:49 AM »
Thanks for both suggestions.  :-) :-)

Is there any reason to prefer one version over the other?

Cheers

Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2

scottcd

  • Newt
  • Posts: 52
Re: How to freeze a list of layers?
« Reply #4 on: September 30, 2008, 08:56:28 AM »
Thanks Cab,

I have used your second version - short and sweet!

I didn't know that you could put code in the middle of a command call like that :grazy:

Cheers
Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to freeze a list of layers?
« Reply #5 on: September 30, 2008, 08:57:44 AM »
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to freeze a list of layers?
« Reply #6 on: September 30, 2008, 09:05:19 AM »
Thanks for both suggestions.  :-) :-)

Is there any reason to prefer one version over the other?

Cheers

Scott


The COMMAND version is often slower than the code version.
The COMMAND version may stop working with a different version of ACAD IF they change the
order of the prompts or the key word.
The COMMAND version is usually shorter code and easy for the novice to create.

Some programmers see the COMMAND version as SCRIPT writing and not real programing.  :-)
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.

GDF

  • Water Moccasin
  • Posts: 2081
Re: How to freeze a list of layers?
« Reply #7 on: September 30, 2008, 10:23:00 AM »
Thanks guys, I've learned something this morning.

I use the command version instead of a script now for controlling my layers in xrefs.

Code: [Select]
(defun c:1ST  (/ 1st str)
  (setq lst '("*DEF*" "*|A-ALT-WIND-2" "*|A-ALT-WIND-3" "*|A-AREA*" "*|A-CLNG*"
              "*|A-DOOR-CODE" "*|A-DIMS*" "*|JUNK" "*|A-NOTE*" "*|A-PATT*"
              "*A-SHTT*" "*|A-SYMB*" "*|LS*" "*|X-LINE*"))
  (setq str "")
  (mapcar '(lambda (x) (setq str (strcat str x ","))) lst)
  (command "_-layer" "_F" str "")
  (command "_-layer" "_T" "*|A-ALT-WIND-1" "")
  (princ))
(defun c:3RD  (/ 1st str)
  (setq lst '("*DEF*" "*|A-ALT-WIND-1" "*|A-ALT-WIND-3" "*|A-AREA*" "*|A-CLNG*"
              "*|A-DOOR-CODE" "*|A-DIMS*" "*|JUNK" "*|A-NOTE*" "*|A-PATT*"
              "*A-SHTT*" "*|A-SYMB*" "*|LS*" "*|X-LINE*"))
  (setq str "")
  (mapcar '(lambda (x) (setq str (strcat str x ","))) lst)
  (command "_-layer" "_F" str "")
  (command "_-layer" "_T" "*|A-ALT-WIND-2" "")
  (princ))

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

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to freeze a list of layers?
« Reply #8 on: September 30, 2008, 10:51:29 AM »
One more method:
http://www.theswamp.org/index.php?topic=690.msg16138#msg16138


CHA-CHING! ...That's where that code snip i had in my notes came from; i had my suspicions a bit of code i had in a file was from Stig, but now i have the proof.

Thanx CAB.

*[Se7en:] runs off to locate and comment code.*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to freeze a list of layers?
« Reply #9 on: September 30, 2008, 12:41:00 PM »
I think that You need to verify if the layer exist before..
and verify if you aren't to a layer who need to be freeze
You can not freeze current layer.

Code: [Select]
(setq layerlisttofreeze
       '("G8010001" "G8010004" "G8010010" "G8010015" "G8010021" "G8010026" "G8010027"
"G8010030" "G8010032" "G8010035" "G8010036" "G8010052" "G8010057" "G8010059"
"G8010071" "G8010072" "G8010098" "G8010321" "G8010374" "G8010376" "G8010382"
"G8010388" "G8010397" "G8010400" "G8010570" "G8010572" "G8011000" "G8011005"
"G8011006" "G8011009" "G8011010"))

(foreach l layerlisttofreeze
  (if (and
(not (eq (strcase (getvar "CLAYER")) (strcase l)))
(member (strcase l) (mapcar 'strcase (ai_table "LAYER" 4)))
      )
    (vl-cmdf "._-Layer" "_F" l "")
   )
)
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to freeze a list of layers?
« Reply #10 on: September 30, 2008, 01:14:21 PM »
The layer command doesn't care if the layer exist or not and will ignore the current layer but will notify you of the fact.
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.

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to freeze a list of layers?
« Reply #11 on: September 30, 2008, 01:20:03 PM »
Command, vl-cmdf are SLOW! Please dont use them. Use either entmod or vl property functions to preform your operations.

I think that You need to verify if the layer exist before..
and verify if you aren't to a layer who need to be freeze
You can not freeze current layer.


that's only cause your using ``command''.  Use entmod and you can (I wouldn't recommend it but...):
Code: [Select]
( (lambda ( / laylst )
   (setq laylst (entget (tblobjname "LAYER" (getvar 'CLAYER))))
   (entmod
    (subst
     (cons 70 (boole 6 (cdr (assoc 70 laylst)) 1))
     (assoc 70 laylst)
     laylst))) )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to freeze a list of layers?
« Reply #12 on: September 30, 2008, 01:21:29 PM »
you'r right CAB,

Code: [Select]
(foreach l layerlisttofreeze
  (if (member (strcase l) (mapcar 'strcase (ai_table "LAYER" 4)))     
    (vl-cmdf "._-Layer" "_F" l "")
   )
)
Keep smile...

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to freeze a list of layers?
« Reply #13 on: September 30, 2008, 01:28:33 PM »


Just for the sake of conversation (Assuming the following code was a valid solution):
Code: [Select]
(foreach l layerlisttofreeze
  (if (member (strcase l) (mapcar 'strcase (ai_table "LAYER" 4)))     
    (vl-cmdf "._-Layer" "_F" l "")
   )
)

Why are you issuing the ``command'' over and over again for the list of layers? The layer command takes a list of layers...comma separated. Your taking a slow process and making it even slower!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How to freeze a list of layers?
« Reply #14 on: September 30, 2008, 01:42:09 PM »
Code: [Select]
Command: [color=red]-LA[/color]
-LAYER
Current layer:  "0"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte]:[color=red] F[/color]
Enter name list of layer(s) to freeze or <select objects>: [color=red]G8*[/color]
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte]:

:-)
TheSwamp.org  (serving the CAD community since 2003)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to freeze a list of layers?
« Reply #15 on: September 30, 2008, 02:11:30 PM »
you'r right Se7en....
your code is faster...

Tested for 100 layers.

thanks.


this code below will regen eachtime the drawing if the layer is already frozen.
do wee need to put some check before running the entmod ?


Code: [Select]
;;; begin timing functions by SMadsen
(defun startTimer ()
  (setq time (getvar "DATE"))
  )


(defun endTimer (func)
  (setq time    (- (getvar "DATE") time)
        seconds (* 86400.0 (- time (fix time)))
        )
  (gc)
  (outPut seconds func)
  )

(defun outPut (secs def)
  (gc)
  (princ (strcat "\nTimed " def ": " (rtos secs 2 6)))
  (princ)
  )




(defun c:freeze1 ()
  (startTimer)
(setq Laylst nil)
(setq v 1)
(repeat 100
  (setq LayLst (append LayLst (list (strcat "CALQUE" (itoa v)))))
  (setq v (1+ v))
)

(mapcar '(lambda (x)  
(setq LayEnt (entget (tblobjname "LAYER" x)))
(entmod (subst (cons 70 (boole 6 (cdr (assoc 70 LayEnt)) 1))
     (assoc 70 LayEnt)
     LayEnt)))
     LayLst)

 (endTimer "c:freeze1");;0.016013
 )


(defun c:freeze2 ()
  (startTimer)
(setq Laylst nil)
(setq v 1)
(repeat 100
  (setq LayLst (append LayLst (list (strcat "CALQUE" (itoa v)))))
  (setq v (1+ v))
)

  (foreach l LayLst
  (if (member (strcase l) (mapcar 'strcase (ai_table "LAYER" 4)))     
    (vl-cmdf "._-Layer" "_F" l "")
   )
)

 (endTimer "c:freeze2");;1.124999
 )
Keep smile...

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to freeze a list of layers?
« Reply #16 on: October 01, 2008, 05:01:33 PM »
Not quite sure I understand what you mean by ``check entmod'' but you can check each layers group code 70 with a simple logand or meybe even use (boole 7...). It kinda depends on what you want and what you want to check for.

For the new users to Autolisp (Things you should take from this topic):

Dont concern yourself with the speed of entmod/make vs VL functions.

If your not comfortable with using entmod/make or the VL functions you can still have a safe, robust, and good application using command. Command is perfectly fine for most applications and uses, you just need to set yourself up properly (Think before coding). To give you a small example:

If you wanted to use command, here is some code I would try and use vs the previous posted versions all the previous versions start and finish the layer command for every layer in the list (For a list of 100 layers that means that the layer command starts and stops a 100 times).

Here is what my application would look like (Note, i just typed this up and only tested it once to see if it worked--this was a fast quickie-).
Code: [Select]
;;
;; This is my custom layer freezing application
;;
;; created by:
;; date created:
;;
;; notes:
;;
;; TODO:

;; ------------------
;; support procedure
;; ------------------
        (defun addcommas (items)
          (if (null items)
            nil
              (cons
                (if (null (cdr items))
                  (list (car items))
                  (list (car items) ",") )
                (addcommas (cdr items)))) )
;; a quick small procedure to parse and add a comma to each item in a list

;; ...

(setq layer-lst
      '("G8010001" "G8010004" "G8010010" "G8010015" "G8010021" "G8010026" "G8010027"
        "G8010030" "G8010032" "G8010035" "G8010036" "G8010052" "G8010057" "G8010059"
        "G8010071" "G8010072" "G8010098" "G8010321" "G8010374" "G8010376" "G8010382"
        "G8010388" "G8010397" "G8010400" "G8010570" "G8010572" "G8011000" "G8011005"
        "G8011006" "G8011009" "G8011010")
;; Set up layer name list.
      layer-lst (apply 'strcat (apply 'append (addcommas layer-lst))) )
;; Make a comma seperated list from the layer names.

(command "-layer" "fr" layer-lst "")
;; freeze the layers

;; ...

This is also the answer to the initial question (Here is your `push' Scott).

Quote
> How to freeze a list of layers?
> « on: Today at 06:02:50 am »
>    
> I have the following list of layers (filtered_layerlist)
>
> ("G8010001" "G8010004" "G8010010" "G8010015" "G8010021" "G8010026" "G8010027"
> "G8010030" "G8010032" "G8010035" "G8010036" "G8010052" "G8010057" "G8010059"
> "G8010071" "G8010072" "G8010098" "G8010321" "G8010374" "G8010376" "G8010382"
> "G8010388" "G8010397" "G8010400" "G8010570" "G8010572" "G8011000" "G8011005"
> "G8011006" "G8011009" "G8011010")
>
> I was trying to use the following to freeze all the layers in the above list
>
> (mapcar '(lambda (x) (command "layer" "freeze" x "") filtered_layerlist))
>
> But I know the syntax is not correct for a start - can anyone give
> me a push in the right direction.
>
> Cheers
>
> Scott
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to freeze a list of layers?
« Reply #17 on: October 01, 2008, 06:15:07 PM »
You'r right Se7en.  :-)

Code: [Select]
(command "[color=red]._[/color]-layer" "[color=red]_[/color]fr" layer-lst "")
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to freeze a list of layers?
« Reply #18 on: October 01, 2008, 06:24:54 PM »
Personally I'm a believer in simplicity.

Most of us spend longer reading code and working out exactly what it does than could be saved by a 50 millisecond decrease in speed for 8000 iterations over the posted list.

This seems demonstrably correct and transparent ... a big advantage !
Code: [Select]
(setq LayerList '("G8010001"      "G8010004"      "G8010010"
                  "G8010015"      "G8010021"      "G8010026"
                  "G8010027"      "G8010030"      "G8010032"
                  "G8010035"      "G8010036"      "G8010052"
                  "G8010057"      "G8010059"      "G8010071"
                  "G8010072"      "G8010098"      "G8010321"
                  "G8010374"      "G8010376"      "G8010382"
                  "G8010388"      "G8010397"      "G8010400"
                  "G8010570"      "G8010572"      "G8011000"
                  "G8011005"      "G8011006"      "G8011009"
                  "G8011010"
                 )
)

(defun c:testmake (/)
    (foreach layerName LayerList (command "_-layer" "_M" layerName ""))
    (princ)
)

(defun c:testThaw (/)
    (foreach layerName LayerList (command "_-layer" "_T" layerName ""))
    (princ)
)

(defun c:testFreeze (/ StringList)
    (foreach layerName LayerList (command "_-layer" "_F" layerName ""))
    (princ)
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to freeze a list of layers?
« Reply #19 on: October 01, 2008, 09:01:40 PM »
you are absolutely right kerry, but even the simplest of procedures can be improved with a very simple modification. granted, one can just continue to say that until they've turned it into something complicated again.
i would change one thing from your route, that is for it to iterate only through the function for each layer, rather than iterating through the full function each time, mainly for freeze, thaw, and off you can just hit the layerp once to restore previous layer states. i'm probably just being nit-picky; i also just wanted to join in on the fun.

Code: [Select]
(setq LayerList '("G8010001"      "G8010004"      "G8010010"
                  "G8010015"      "G8010021"      "G8010026"
                  "G8010027"      "G8010030"      "G8010032"
                  "G8010035"      "G8010036"      "G8010052"
                  "G8010057"      "G8010059"      "G8010071"
                  "G8010072"      "G8010098"      "G8010321"
                  "G8010374"      "G8010376"      "G8010382"
                  "G8010388"      "G8010397"      "G8010400"
                  "G8010570"      "G8010572"      "G8011000"
                  "G8011005"      "G8011006"      "G8011009"
                  "G8011010"
                 )
)


(defun c:testmake (/)
  (command "_-layer"
  (foreach layername LayerList  (command "_M" layername))
  (command "")
  (princ)
)

(defun c:testThaw (/)
  (command "_-layer"
  (foreach layername LayerList  (command "_T" layername))
  (command "")
  (princ)
)

(defun c:testFreeze (/)
  (command "_-layer"
  (foreach layername LayerList (command "_F" layername))
  (command "")
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to freeze a list of layers?
« Reply #20 on: October 02, 2008, 09:32:40 AM »
Im only iterating 3 times...So *Ptthhht!* :p

Kerry, I agree with your desire for clean easy code but in my opinion that iteration of the layer command for every layer is sloppy; I understand your point about us having a set list of layers and the unnecessary need to `set up' but I dont like to insinuate that this is the correct process for all situations.

Why? Because: 8000 list iterations is going to be a lot faster then 100 command iterations any day.  I would rather teach someone to think about how they can iterate a list ten times over in an effort to get it done right the first time then to waste time later trying to speed up a seeming simple process they havent spent enough time thinking about in the first place.


TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to freeze a list of layers?
« Reply #21 on: October 02, 2008, 12:31:43 PM »
very good point. seems best to learn to work smart, not fast and simple.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to freeze a list of layers?
« Reply #22 on: October 02, 2008, 03:28:23 PM »
....  8000 list iterations is going to be a lot faster then 100 command iterations any day.  ...

time for a wager I think ??


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to freeze a list of layers?
« Reply #23 on: October 02, 2008, 03:49:03 PM »
....  8000 list iterations is going to be a lot faster then 100 command iterations any day.  ...

time for a wager I think ??


*lol* ...If its going to be for a beer, we'll have to settle for a check made out for the amount cause the dry ice and the shipping would be a pain in the butt.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How to freeze a list of layers?
« Reply #24 on: October 02, 2008, 09:17:13 PM »
Dont concern yourself with the speed of entmod/make vs VL functions.

Thank you Seven for this lesson, and Thanks to Cab's post about Command verses "Code"  and to everyone else that chimed. 

But my question is why put it into a "SETQ" list to begin with.  Why not throw the list right into the Script code since the you are using the COMMAND and the list is known.  I can understand culling something for a list but with it known it makes little sense.  For example I have use this code below to freeze certain layers with a file. 

Code: [Select]
;;;  THAWING OF RCP LAYERS AND FREEZING FLOOR PLAN LAYERS.
(defun c:RCPT ()

  (vl-load-com)
  (vl-cmdf ".undo" "BEGIN")
  (setvar "CMDECHO" 0)

  (VL-CMDF "-LAYER" "T" "*RCP*" "")
  (VL-CMDF
    "-LAYER"
    "F"    "*PLUMB*,*WIND*,*DOOR*,*ADA*,*AREA*,*REFERENCE*,*FURN*,*APPL*,*CASEWORK*,*CABINETS*,*DIM*,*STAIR*,*STAIR*TEXT*,*ELEC*,*HANDRAIL*,*PARTIT*"
    ""
  )

  (setvar "CMDECHO" 1)
  (vl-cmdf ".undo" "END")
  (princ)
)

Please understand that my lisping capabilities are equal to that of an 3rd grader especially when compared to you professors with doctorates.   So I am becuase I know there is a good reason as to why it being coded with a SETQ list and I want to find out.   Again thank you for the lessons.  :-)
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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to freeze a list of layers?
« Reply #25 on: October 02, 2008, 10:17:47 PM »



But my question is why put it into a "SETQ" list to begin with.  Why not throw the list right into the Script code since the you are using the COMMAND and the list is known.  I can understand culling something for a list but with it known it makes little sense.  For example I have use this code below to freeze certain layers with a file. 


The user MAY require a list for several disciplines, or for several clients, and the list MAY also be dynamic .. dependant on other criteria.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to freeze a list of layers?
« Reply #26 on: October 03, 2008, 12:56:35 AM »
A tangent but ... what should be central to one's coding philosophy are strategies that minimize code maintenance and maximize code reuse. Often just a little extra effort to attempt to forecast how might a particular algorithm may be used down the road will make apparent a more effective way to define and code a function, and that's exactly what Kerry is pointing out. The user MAY require a list for several disciplines, or for several clients, and the list MAY also be dynamic ... dependent on other criteria.

Two things you can do to address this are (1) design as generically as is practical, but not to the point where a function is so ambitious it becomes an unwieldy behemoth, and (2) design an interface (function signature and return type) you can continue to honor over time so that client functions are not broken when changes or improvements to the implementation occur.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

scottcd

  • Newt
  • Posts: 52
Re: How to freeze a list of layers?
« Reply #27 on: October 03, 2008, 04:43:48 AM »
I am in the middle of developing a dynamic layer filter and dockable dialogue box and this was part of the process - how to pass the filtered layer list to the layer command.

Thanks for all the help and insight.

I have attached an image to give you an idea of what I am trying to - with ODCL.

Cheers

Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2