Author Topic: Freeze specific layer on each layout (NOT global freeze!)  (Read 3510 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 635
Freeze specific layer on each layout (NOT global freeze!)
« 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
« Last Edit: March 13, 2017, 10:28:02 AM by kruuger »

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #1 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).
« Last Edit: March 13, 2017, 10:46:13 AM by gile »
Speaking English as a French Frog

hawstom

  • Newt
  • Posts: 22
  • AutoCAD Civil 3D, Mesa, AZ, USA
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #2 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.  
« Last Edit: March 13, 2017, 04:21:46 PM by hawstom »
Not so terse now.  You may not feel so clever in 6 months or years.  http://lisp-lang.org/style-guide/
hawsedc.com, and autocad.wikia.com

kruuger

  • Swamp Rat
  • Posts: 635
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #3 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).
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?


hawstom

  • Newt
  • Posts: 22
  • AutoCAD Civil 3D, Mesa, AZ, USA
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #4 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.
Not so terse now.  You may not feel so clever in 6 months or years.  http://lisp-lang.org/style-guide/
hawsedc.com, and autocad.wikia.com

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #5 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
« Last Edit: March 13, 2017, 06:02:26 PM by gile »
Speaking English as a French Frog

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #6 on: March 13, 2017, 05:57:30 PM »
@hawstom:
Reading your code I notice that the I variable is never incremented.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #7 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.

hawstom

  • Newt
  • Posts: 22
  • AutoCAD Civil 3D, Mesa, AZ, USA
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #8 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?
« Last Edit: March 13, 2017, 06:25:05 PM by hawstom »
Not so terse now.  You may not feel so clever in 6 months or years.  http://lisp-lang.org/style-guide/
hawsedc.com, and autocad.wikia.com

kruuger

  • Swamp Rat
  • Posts: 635
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #9 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




kruuger

  • Swamp Rat
  • Posts: 635
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #10 on: March 14, 2017, 02:22:38 AM »
But doesn't LAYFRZ do that now?
LAYFRZ freeze them globally. not per layout.

didier

  • Newt
  • Posts: 48
  • expatrié
Re: Freeze specific layer on each layout (NOT global freeze!)
« Reply #11 on: March 14, 2017, 02:35:00 AM »
Coucou

No, with the right settings LayFrz works

amicalement
eternal beginner ...
my english is not fluent ...