Author Topic: Viewport, code 90  (Read 3704 times)

0 Members and 1 Guest are viewing this topic.

Patrick_35

  • Guest
Viewport, code 90
« 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

@+

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Viewport, code 90
« Reply #1 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)

Patrick_35

  • Guest
Re: Viewport, code 90
« Reply #2 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

@+

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Viewport, code 90
« Reply #3 on: July 15, 2008, 03:23:46 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Patrick_35

  • Guest
Re: Viewport, code 90
« Reply #4 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, except for this bit in dxf 90. It is perhaps impossible.

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport, code 90
« Reply #5 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)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Patrick_35

  • Guest
Re: Viewport, code 90
« Reply #6 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.

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport, code 90
« Reply #7 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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Patrick_35

  • Guest
Re: Viewport, code 90
« Reply #8 on: July 16, 2008, 02:45:45 PM »
Thanks, but I try it in paperspace with A2005, and it's don't work

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport, code 90
« Reply #9 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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport, code 90
« Reply #10 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
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Patrick_35

  • Guest
Re: Viewport, code 90
« Reply #11 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
)

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport, code 90
« Reply #12 on: July 17, 2008, 08:47:07 AM »
Well we must work within the limits of ACAD 8-)

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.