Layer viewport freeze LISP not working in 2022

Layer viewport freeze LISP not working in 2022

tim.turner
Advocate Advocate
1,013 Views
2 Replies
Message 1 of 3

Layer viewport freeze LISP not working in 2022

tim.turner
Advocate
Advocate

I have a great LISP that would freeze layers in the active viewport with a mouse pick. Now in 2022 it freezes the layer in all model space. Anyone know what has changed causing this not to work, or can fix it?

Thanks

0 Likes
1,014 Views
2 Replies
Replies (2)
Message 2 of 3

pbejse
Mentor
Mentor

@tim.turner wrote:

Now in 2022 it freezes the layer in all model space.


That is how the program behaves based on this condition

(if (= pLayer cLayer)
 (command "_.layer" "_s" "0" "_off" pLayer "")
 (command "_.vplayer" "_f" pLayer "_c" "")
)

If current layer is the same as the layer name from the selected object. The code invokes "_Layer" command and set the current to "0" and follow up with "_off" while still in "_Layer" command

 

What you can do is this, only set the layer to "0" if the selected objects layer name matches the curent one and immediately step out of the IF statement, leaving the call to _Vplayer to be freeze the selected layer.

(defun c:VF ( / ent cLayer pLayer)
(setq ent (car(entsel "\nSelect object to VP-freeze layer: ")))
(setq cLayer (getvar "clayer"))
(setq pLayer (cdr (assoc 8 (entget ent))))
(if (= pLayer cLayer)
 (command "_.layer" "_s" "0" "")
  )
(command "_.vplayer" "_f" pLayer "_c" "")
(prompt (strcat "Layer " pLayer " frozen in current viewport"))
(princ)
)

HTH

 

0 Likes
Message 3 of 3

ВeekeeCZ
Consultant
Consultant

Why you don't use the LAYFRZ command. There is a setting that while you're in an active VP it performs VPFREEZE, else the classic FREEZE

 

Command: _layfrz
Current settings: Viewports=Vpfreeze, Block nesting level=Block
Select an object on the layer to be frozen or [Settings/Undo]: S

Enter setting type for [Viewports/Block selection]: V

In paper space viewport use [Freeze/Vpfreeze] <Vpfreeze>: *Cancel*

0 Likes