What I am wanting to do is have a lisp that will bring up a list of page layouts in my drawing which I choose the page layouts that I want to freeze certain layers in and after I select them it will then ask me to select which layers to freeze in the view port or multiple view ports. So after that it will go to each page layout one at a time and freeze the layers that I have selected that I do not want on in the viewport? The other way I could think is if it could read the layout tabs name and from what it is called such as FA-1 it is programed to freeze any layers that are do not have FA, Fire Alarm in the name of the layer. There will be obviously more thant just FA-1, it could read IC-1, or AC-1. I hope this has made sense and really hope this is possible just not sure how I would even start a lisp for this one.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@bgraverholt wrote:
...
The other way I could think is if it could read the layout tabs name and from what it is called such as FA-1 it is programed to freeze any layers that are do not have FA, Fire Alarm in the name of the layer. There will be obviously more thant just FA-1, it could read IC-1, or AC-1....
Could you attach a sample DWG with the Layout / Layers structure?
Maybe it's easier to get some help...
Henrique
Here is an example of a drawing with different systems on it with different page layouts.
Later on or tomorrow I'll post a draft.
Henrique
Quick and dirty...
(defun c:demo (/ FA_Freeze LayFreeze lst NC_Freeze PA_Freeze) (defun LayFreeze (layt laylst / ent i ss vp) (setvar 'CTAB layt) (if (setq ss (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 layt)))) (repeat (setq i (sslength ss)) (setq ent (entget (ssname ss (setq i (1- i)))) vp (cdr (assoc 69 ent)) ) (if (> vp 1) (progn (command "_.mspace") (setvar 'CVPORT vp) (command "_.vplayer" "_F" laylst "" "" ) ) ) ) ) (command "_.pspace") ) (setq PA_Freeze "FA-*,FIRE ALARM*,MONITOR*,NURSE CALL*" FA_Freeze "INTERCOM*,MATV,MONITOR*,NURSE CALL*" NC_Freeze "FA-*,FIRE ALARM*,INTERCOM*,MATV" lst (layoutlist) ) (foreach x lst (cond ((wcmatch x "*PA-*") (LayFreeze x PA_Freeze) ) ((wcmatch x "*FA-*") (LayFreeze x FA_Freeze) ) ((wcmatch x "*NC-*") (LayFreeze x NC_Freeze) ) ) ) (princ) )
HTH
Henrique
Nice! You were right quick and dirty haha. That worked great for the first page in that sample drawing. But did the same viewport freezes in the second and third page layouts. Ill have to try and study your lisp to see how it works. New to doing lisps so might take me awhile haha.
That worked great on a regular drawing. Do you know if this will work with xref layers? I tried it on a larger drawing with an xref and it seemed to not run.
@bgraverholt wrote:
That worked great on a regular drawing. Do you know if this will work with xref layers? I tried it on a larger drawing with an xref and it seemed to not run.
The code is hardcoded, so you'll need to supply the code with the layer names to freeze...
(setq PA_Freeze "FA-*,FIRE ALARM*,MONITOR*,NURSE CALL*,*|FA-*,*|FIRE ALARM*,*|MONITOR*,*|NURSE CALL*" FA_Freeze "INTERCOM*,MATV,MONITOR*,NURSE CALL*,*|INTERCOM*,*|MATV,MONITOR*,*|NURSE CALL*" NC_Freeze "FA-*,FIRE ALARM*,INTERCOM*,MATV,*|FA-*,*|FIRE ALARM*,*|INTERCOM*,*|MATV" lst (layoutlist) )
As an exemple with the same layers in a xref...
HTH
Henrique
It seem to work great just need to tweak it alittle bit to work with our other layers we may have. When I run this in one of our xref's its coming back with this
Command: _.mspace
Already in model space.
Command: ; error: AutoCAD variable setting rejected: CVPORT 5
Any way it can do multi viewports?
@bgraverholt wrote:
...
Command: ; error: AutoCAD variable setting rejected: CVPORT 5Any way it can do multi viewports?
I did test the code with multi viewports without error.
To prevent the "error", add to the LayFreeze function a zoom extents...
(defun LayFreeze (layt laylst / ent i ss vp) (setvar 'CTAB layt) (Command "_.zoom" "_E");; <<< here (if (setq ss (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 layt)))) ...
HTH
Henrique
This lisp works flawlessly! All I need to do is add more layers to freeze for the specific pages to get it to work for all jobs. Thanks so much for your help with this!
Brett
This worked great but there was a hot fix to fix the problem of the page layouts from shifting when you click on them and now the lisp wont work for some reason... the link to the hot fix is bellow. I just started to enjoy this lisp I hope there hot fix didn't screw up this lisp from ever working again.
@bgraverholt wrote:
This worked great but there was a hot fix to fix the problem of the page layouts from shifting when you click on them and now the lisp wont work for some reason...
Hi Brett,
I dont understand why the code dont work in AC2015, after the hotfix... Maybe someone who is using AC 2015, can test the code...
Henrique
Any one else have any suggestions??? I have still not been able to figure it out. The only thing I have noticed different with this hotfix is if you accidently click and move your mouse alittle bit it will start a selection on the new view port not sure if that could be the cause. Hopefully someone will be able to help out.