TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: kruuger on March 13, 2017, 10:15:05 AM

Title: Freeze specific layer on each layout (NOT global freeze!)
Post by: kruuger on March 13, 2017, 10:15:05 AM
hello
is there any lisp magic which allows freeze specific layer on each layouts?
it is third icon (for layout) not second (global freeze)
thanks
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: gile on March 13, 2017, 10:34:47 AM
Hi,

AFAIK, with LISP (Vanilla or Visual) there's no other way than calling the VPLAYER command.

I tried to build some AutoLISP functions to override layer properties in viewports with .NET (see here (https://www.theswamp.org/index.php?topic=40876.msg461139#msg461139)).
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: hawstom on March 13, 2017, 04:07:41 PM
Calling a command is nothing to be ashamed of.

Here is little application I wrote that might have what you want somewhere inside it.  Sorry for any bad style and if you don't like all caps.  That's how it was.

Code - Auto/Visual Lisp: [Select]
  1. (SETQ LAYER-OPERATION "_freeze")
  2. (PROMPT "\nPick layers to freeze in current viewport:")
  3. (COMMAND "mspace" "vplayer")
  4. (HAWS-LAYER-LOOP T)
  5. (COMMAND "" "")
  6.  
  7.    HAWS-LAYER-LOOP (VIEWPORT-MODE-P / SELECTION-SET-LAYERS I ENTITY-NAME LAYER-NAME)
  8.   (SETQ
  9.     SELECTION-SET-LAYERS
  10.      (SSGET)
  11.     I 0
  12.   )
  13.   (COND
  14.     (SELECTION-SET-LAYERS
  15.      (WHILE (SETQ ENTITY-NAME (SSNAME SELECTION-SET-LAYERS I))
  16.        (SETQ LAYER-NAME (CDR (ASSOC 8 (ENTGET ENTITY-NAME))))
  17.        (COMMAND LAYER-OPERATION LAYER-NAME)
  18.        (IF VIEWPORT-MODE-P
  19.          (COMMAND "")
  20.        )
  21.     )
  22.   )
  23. )
  24.  
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: kruuger on March 13, 2017, 04:21:33 PM
Hi,

AFAIK, with LISP (Vanilla or Visual) there's no other way than calling the VPLAYER command.

I tried to build some AutoLISP functions to override layer properties in viewports with .NET (see here (https://www.theswamp.org/index.php?topic=40876.msg461139#msg461139)).
hi gile
ok VPLAYER, i think i can deal with this. it freeze layers also in all viewport but that's not a big deal.
thanks for link. any chance to support 2017?

Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: hawstom on March 13, 2017, 04:24:56 PM
thanks for link. any chance to support 2017?

When you use (command) calls, they are usually forward compatible nearly indefinitely.  I haven't been the most nerdy of programmers, but gratefully most of the stuff I programmed in the early 90s has needed very little tweaking to still be going strong today.
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: gile on March 13, 2017, 05:52:18 PM
thanks for link. any chance to support 2017?

LispVpLayer_19.dll should work with A2013 and later.

Edit: After testing, LispVpLayer_19.dll LISP functions do work with A2017
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: roy_043 on March 13, 2017, 05:57:30 PM
@hawstom:
Reading your code I notice that the I variable is never incremented.
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: roy_043 on March 13, 2017, 06:01:35 PM
Note:
In BricsCAD you can change the Xdata of the viewport to accomplish this. But you have to use vla-setxdata as entmod fails on viewports.
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: hawstom on March 13, 2017, 06:10:08 PM
@hawstom:
Reading your code I notice that the I variable is never incremented.

Thanks.  I must have deleted that inadvertently.  But if I were programming that today (instead of 20 years ago) it would of course be in the while condition (among other things I'd do differently)  Here's a still-quick-and-dirty-but-a-little-more-worthy version (not that it seems to really matter for the purposes of this thread):

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ffv () (c:haws-vpfreeze))
  2.    c:haws-vpfreeze (/ selection-set-layers i entity-name layer-name)
  3.   (command "._mspace")
  4.   (princ "\nPick layers to freeze in current viewport: ")
  5.   (setq
  6.     selection-set-layers
  7.      (ssget)
  8.     layer-operation "_freeze"
  9.     i -1
  10.   )
  11.   (cond
  12.     (selection-set-layers
  13.      (command "._vplayer")
  14.      (while (setq entity-name (ssname selection-set-layers (setq i (1+ i))))
  15.        (setq layer-name (cdr (assoc 8 (entget entity-name))))
  16.        (command layer-operation layer-name)
  17.        (if viewport-mode-p
  18.          (command "")
  19.        )
  20.      )
  21.      (command "" "")
  22.     )
  23.   )
  24. )
  25.  

But doesn't LAYFRZ do that now?
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: kruuger on March 14, 2017, 02:21:55 AM
thanks for link. any chance to support 2017?

LispVpLayer_19.dll should work with A2013 and later.

Edit: After testing, LispVpLayer_19.dll LISP functions do work with A2017
yes, works well, thanks



Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: kruuger on March 14, 2017, 02:22:38 AM
But doesn't LAYFRZ do that now?
LAYFRZ freeze them globally. not per layout.
Title: Re: Freeze specific layer on each layout (NOT global freeze!)
Post by: didier on March 14, 2017, 02:35:00 AM
Coucou

No, with the right settings LayFrz works

amicalement