TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Patrick_35 on July 15, 2008, 11:38:25 AM

Title: Viewport, code 90
Post 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

@+
Title: Re: Viewport, code 90
Post by: Jeff_M on July 15, 2008, 11:45:37 AM
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)
Title: Re: Viewport, code 90
Post by: Patrick_35 on July 15, 2008, 02:27:44 PM
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

@+
Title: Re: Viewport, code 90
Post by: ronjonp on July 15, 2008, 03:23:46 PM
Maybe this will help out:

http://www.theswamp.org/index.php?topic=10992.msg139778#msg139778
Title: Re: Viewport, code 90
Post by: Patrick_35 on July 16, 2008, 02:57:56 AM
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.

@+
Title: Re: Viewport, code 90
Post by: CAB on July 16, 2008, 11:37:31 AM
Try this:
Code: [Select]
;;  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
)

Code: [Select]
(defun c:test(/ lst)
  (setq lst (view t))
  (mapcar 'print lst)
  (princ)
)
Title: Re: Viewport, code 90
Post by: Patrick_35 on July 16, 2008, 12:00:54 PM
Thanks cab

But ViewportOn only works if the layout on which the viewport has already been activated at least once.

@+
Title: Re: Viewport, code 90
Post by: CAB on July 16, 2008, 12:17:55 PM
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.
Title: Re: Viewport, code 90
Post by: Patrick_35 on July 16, 2008, 02:45:45 PM
Thanks, but I try it in paperspace with A2005, and it's don't work

@+
Title: Re: Viewport, code 90
Post by: CAB on July 16, 2008, 02:57:32 PM
I just tried in the ACAD2004 and no go. :-(

Must neet to refresh the layouts before the variables are set properly.
Title: Re: Viewport, code 90
Post by: CAB on July 16, 2008, 07:15:55 PM
Works but not what you wanted.
Code: [Select]
;;  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
)
Title: Re: Viewport, code 90
Post by: Patrick_35 on July 17, 2008, 02:55:56 AM
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  :-(

Code: [Select]
;;  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
)

@+
Title: Re: Viewport, code 90
Post by: CAB on July 17, 2008, 08:47:07 AM
Well we must work within the limits of ACAD 8-)