Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP HELP WITH FREEZING LAYERS IN VIEW PORTS

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
bgraverholt
568 Views, 16 Replies

LISP HELP WITH FREEZING LAYERS IN VIEW PORTS

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.

16 REPLIES 16
Message 2 of 17
bgraverholt
in reply to: bgraverholt

Any one have any suggestions or could help me?

Message 3 of 17
hmsilva
in reply to: bgraverholt


@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

EESignature

Message 4 of 17
bgraverholt
in reply to: hmsilva

Here is an example of a drawing with different systems on it with different page layouts.

Message 5 of 17
hmsilva
in reply to: bgraverholt

I'll see what I can do.

Later on or tomorrow I'll post a draft.

 

Henrique

EESignature

Message 6 of 17
hmsilva
in reply to: bgraverholt

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

EESignature

Message 7 of 17
bgraverholt
in reply to: hmsilva

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.

Message 8 of 17
hmsilva
in reply to: bgraverholt

The above code was fixed...

 

HTH

Henrique

EESignature

Message 9 of 17
bgraverholt
in reply to: hmsilva

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. 

Message 10 of 17
hmsilva
in reply to: bgraverholt


@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

 

EESignature

Message 11 of 17
bgraverholt
in reply to: hmsilva

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?

 

 

 

 

 

 

Message 12 of 17
hmsilva
in reply to: bgraverholt


@bgraverholt wrote:

...
Command: ; error: AutoCAD variable setting rejected: CVPORT 5

Any 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

EESignature

Message 13 of 17
bgraverholt
in reply to: hmsilva

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

Message 14 of 17
hmsilva
in reply to: bgraverholt

You're welcome, Brett
Glad I could help

Henrique

EESignature

Message 15 of 17
bgraverholt
in reply to: hmsilva

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.

 

 

http://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autodesk-C2-AE-autoca...

Message 16 of 17
hmsilva
in reply to: bgraverholt


@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

EESignature

Message 17 of 17
bgraverholt
in reply to: hmsilva

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost