View Full Version : Lisp to change from off to frozen in viewport
tyeelaw13
2007-06-19, 06:20 PM
Hello,
I wanted to see if anyone has a lisp routine that will take layers that are turned off in a viewport and change them to frozen in the viewport.
Thanks in advance.
FRAMEDNLV
2007-06-19, 06:45 PM
I don't think that you can turn off layers in a viewport. I believe they are on or off for all viewports.
Chris
tyeelaw13
2007-06-19, 08:05 PM
We have an outside programmer that runs his program and it does its thing so the floor, ceiling plan etc show up the way they need to, but yes you're right. He's used to using a real old version of cad, so that's why i'm looking to see if you can change the layer states from off to frozen so the multiple viewports we have can corespond with his programming.
Look at the VPLAYER AutoCAD command.
CAB2k
2007-06-19, 10:26 PM
We have an outside programmer that runs his program and it does its thing so the floor, ceiling plan etc show up the way they need to, but yes you're right. He's used to using a real old version of cad, so that's why i'm looking to see if you can change the layer states from off to frozen so the multiple viewports we have can corespond with his programming.
So, you want to read the off layers & freeze them in a particular view port?
What layer manager are you using? Express tools lman or the built-in layer states manager?
Will you set the layer states & then call a lisp to select a viewport to freeze layers in?
tyeelaw13
2007-06-20, 04:39 PM
Again, it's an outside programmers layer manager. His stuff is used to running in r14, so the vplayer thing wasn't around then. His programming turns off the layers according to what the go with (ceiling, floor etc...), but now that we want to add multiple viewports, all those layers that were only turned "off" need to be "frozen"
kennet.sjoberg
2007-06-20, 05:00 PM
. . . "off" need to be "frozen"
Why can't they remain "off" ?
: ) Happy Computing !
kennet
CAB2k
2007-06-20, 05:03 PM
Again, it's an outside programmers layer manager.
So you are running this routine too?
His stuff is used to running in r14, so the vplayer thing wasn't around then. His programming turns off the layers according to what the go with (ceiling, floor etc...),
I understand all that, just want to know how you deal with setting the layers off and on.
but now that we want to add multiple viewports, all those layers that were only turned "off" need to be "frozen"
Frozen in a viewport you select?
Just trying to be specific about the task at hand.
Pseudo code:
you turn the off layers off with another lisp
This lisp is started
You select a view port
Lock layers in viewport for each layer that is currently off
End of routine
Does that seem like a workable solution?
CAB2k
2007-06-20, 05:49 PM
Maybe this will work for you.
;; CAB 07.19.2007
;; Freeze layers in selected viewport for all OFF layers
(defun c:FrzInVP (/ LAYLST USERCMD VP)
(vl-load-com)
;; get OFF layers
(defun getOfflayers (doc / lst)
(setq lst "")
(vlax-for layObj (vla-get-layers doc)
(if (eq (vla-get-layeron layObj) :vlax-false)
(setq lst (strcat lst (vla-get-name layObj) ","))
)
)
lst
)
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "_.UNDO" "_BEgin")
(if
(and
(setq vp (vp_sel))
(or
(not (eq (setq
LayLst (getOfflayers
(vla-get-activedocument (vlax-get-acad-object))
)
)
""
)
)
(prompt "\nError - No OFF layers.")
)
)
(command "._vplayer" "Freeze" LayLst "Current" "")
)
(command "_.UNDO" "_End")
(setvar "CMDECHO" usercmd)
(princ)
)
(prompt "\nFreeze Off layers in Viewport Loaded, Enter FrxInVP to run.")
(princ)
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; + Viewport Select +
;;; + Created by C. Alan Butler +
;;; + Copyright 2005 +
;;; + by Precision Drafting & Design All Rights Reserved. +
;;; + Contact at ab2draft@TampaBay.rr.com +
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; Returns the viewport entity name, ignoring second entities used when
;;; a non-standard viewport is created, circle, ellipse, LWpolyline
(defun vp_sel (/ vpflag sel-vport entvport vptest)
(if (= (getvar "TileMode") 1) ; in model space
;;------------------------------------------------
(progn
(alert "**** You must be in Paper Space to run this routine. ****")
)
;;------------------------------------------------
(progn ;else in a layout
(if (/= (getvar "cvport") 1)
(command "_pspace") ; close the view port
)
(setq vpflag (getvar "cvport")) ; get viewport #
(while (= vpflag 1) ; No active viewport, Loop until one is picked
(setq sel-vport (car (entsel "\nSelect view port: ")))
(if (= sel-vport nil)
(alert
"You must select a viewport\r\n --=< Try again! >=--"
)
(progn
(setq entvport (entget sel-vport))
(if (and ;; not all vp objects are LWPolylines
;;(= (cdr (assoc 0 entvport)) "LWPOLYLINE")
(setq vptest (member '(102 . "{ACAD_REACTORS") entvport))
(setq vptest (member '(102 . "}") (reverse vptest)))
(assoc 330 vptest)
)
(setq entvport (entget (cdr (assoc 330 vptest))))
)
;; Make VP active
(if (= (cdr (assoc 0 entvport)) "VIEWPORT")
(progn
(setq vpflag (cdr (assoc 69 entvport)))
(command "mspace") ; activate the last vp active
(setvar "cvport" vpflag) ; switch to this vp
) ; endif viewport
)
)
) ; endif cond sel-vport
) ;endwhile (= vpFlag 1)
)
)
;; return the ename of vp or nil
(cond (entvport (cdr(assoc -1 entvport))))
)
Again, it's an outside programmers layer manager. His stuff is used to running in r14, so the vplayer thing wasn't around then. His programming turns off the layers according to what the go with (ceiling, floor etc...), but now that we want to add multiple viewports, all those layers that were only turned "off" need to be "frozen"
VPLAYER (http://www.hyperpics.com/commands/) has been around at least since R12.
tyeelaw13
2007-06-21, 04:32 PM
well i think the original code was written without respect to multiple viewports in a drawing. They can remain off, but if they get turned on, then they turn on in all viewports. We just want to be able to take the layers that his programs turns off, and change them to frozen.
Thanks everyone
CAB2k
2007-06-21, 07:37 PM
OK, try this:
;; CAB 07.20.2007
;; Freeze all OFF layers
;; If current layer is off, Layer 0 is thawed and made current
(defun c:Off2Frozen (/ doc clayer layobj lname lay0)
(vl-load-com)
(setq xref_ok nil) ; nil = ignore xref off layers
(setq clayer (getvar "clayer"))
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-endundomark doc)
(vla-startundomark doc)
(vlax-for layObj (vla-get-layers doc)
(and
(setq lname (vla-get-name layobj))
(or (not(eq lname "0")) (setq lay0 layobj))
(eq (vla-get-layeron layObj) :vlax-false)
(vlax-property-available-p layobj 'freeze t)
(or (not (wcmatch lname "*|*")) xref_ok)
(or (not (eq lname clayer))
(or (not lay0) (vla-put-freeze lay0 :vlax-false))
(setvar "clayer" "0"))
(vla-put-freeze layobj :vlax-true)
)
)
(vla-endundomark doc)
(princ)
)
(prompt "\nFreeze Off layers Loaded, Enter Off2Frozen to run.")
(princ)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.