TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Patrick_35 on July 15, 2008, 11:38:25 AM
-
Hello
Do you know correspondence vlisp a viewport for code dxf 90, bit 131072 (without use vla-display...)
Thanks
@+
-
If you mean you'd like to change it via (entmod) and not ActiveX, you can't. (Entmod) does not work with Viewports, so you must either use a Command call or (vla-display VP :vlax-false)
-
Thank you for your reply.
I know, it's just to see if a viewport is active or not, which is the code dxf 90.
I found the property ViewPortOn, but it only works if the layout on which the viewport was activated
@+
-
Maybe this will help out:
http://www.theswamp.org/index.php?topic=10992.msg139778#msg139778
-
Thanks ronjonp
That's exactly it, except that I seek to do the same thing in vlisp.
I am almost (http://www.theswamp.org/index.php?topic=10992.msg287681#msg287681), except for this bit in dxf 90. It is perhaps impossible.
@+
-
Try this:
;; CAB 07/16/2008 TheSwamp.org
;; Return a list of Tab names & viewport object names
;; If on? is true return only viewports that are ON
;; else return ALL viewports
;; Ignore Model Space
(defun view (on? / doc layout obj vp-list first-vp result)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for layout (vla-get-layouts doc)
(setq vp-list nil)
(if (/= (vla-get-name layout) "Model")
(progn
(setq first-vp t) ; ignore the layout vp
(vlax-for obj (vla-get-block layout)
(if (and (eq (vla-get-objectname obj) "AcDbViewport")
(or (not on?) (eq (vla-get-ViewportOn obj) :vlax-true))
)
(if first-vp
(setq first-vp nil)
(setq vp-list (cons obj vp-list))
)
)
)
(and vp-list
(setq result (cons (list (vla-get-name layout) vp-list) result))
)
)
)
)
result
)
(defun c:test(/ lst)
(setq lst (view t))
(mapcar 'print lst)
(princ)
)
-
Thanks cab
But ViewportOn only works if the layout on which the viewport has already been activated at least once.
@+
-
Testing with ACAD2000 it works fine in a newly opened drawing, no layouts active.
DWG opened in Model Space & the test routine ran fine, ignoring the Not On viewports.
-
Thanks, but I try it in paperspace with A2005, and it's don't work
@+
-
I just tried in the ACAD2004 and no go. :-(
Must neet to refresh the layouts before the variables are set properly.
-
Works but not what you wanted.
;; CAB 07/16/2008 TheSwamp.org
;; Return a list of Tab names & viewport object names
;; If on? is true return only viewports that are ON
;; else return ALL viewports
;; Ignore Model Space
(defun view (on? / doc layout obj vp-list first-vp result)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for layout (vla-get-layouts doc)
(setq vp-list nil)
(if (/= (vla-get-name layout) "Model")
(progn
(setq first-vp t) ; ignore the layout vp
(vlax-for obj (vla-get-block layout)
(if (and (eq (vla-get-objectname obj) "AcDbViewport")
(or (not on?) (vla-put-activelayout doc layOUT)
(eq (vla-get-ViewportOn obj) :vlax-true))
)
(if first-vp
(setq first-vp nil)
(setq vp-list (cons obj vp-list))
)
)
)
(and vp-list
(setq result (cons (list (vla-get-name layout) vp-list) result))
)
)
)
)
result
)
-
Thanks cab
It is always interesting to see lisps other. :-)
As is vlisp and that I would like to eliminate the viewport that are inactive, it me to use vlax-vla-object->ename. I liked to stay in vlisp :-(
;; CAB 07/16/2008 TheSwamp.org
;; Modified by Patrick_35 07/17/2008
;; Return a list of Tab names & viewport object names
;; Ignore Model Space
(defun view (/ doc layout obj vp-list first-vp result)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for layout (vla-get-layouts doc)
(setq vp-list nil)
(if (/= (vla-get-name layout) "Model")
(progn
(setq first-vp nil) ; ignore the layout vp
(vlax-for obj (vla-get-block layout)
(if (and (eq (vla-get-objectname obj) "AcDbViewport")
first-vp
(zerop (logand (cdr (assoc 90 (entget (vlax-vla-object->ename obj)))) 131072))
)
(setq vp-list (cons obj vp-list))
(setq first-vp T)
)
)
(and vp-list
(setq result (cons (list (vla-get-name layout) vp-list) result))
)
)
)
)
result
)
@+
-
Well we must work within the limits of ACAD 8-)