Viewport scale value

Discussion in 'AutoCAD' started by Hanksor, Apr 26, 2004.

  1. Hanksor

    Hanksor Guest

    Is there a way to get the current scale of an active viewport? It seems
    that there is, but I'm having a "brain fart" at the moment. Any help will
    be appreciated.

    Hanksor
     
    Hanksor, Apr 26, 2004
    #1
  2. Hanksor

    jclaidler Guest

    (last (trans '(0 0 1) 3 2))
     
    jclaidler, Apr 26, 2004
    #2
  3. Hanksor

    Devin Guest

    Try,

    (setq obj (vlax-ename->vla-object (car (entsel "\nSelect paperspace
    viewport: "))))
    (vla-get-customScale obj)

    HTH,

    Devin
     
    Devin, Apr 26, 2004
    #3
  4. Hanksor

    kendresen Guest

    This will not work with polygonal viewports.

    (setq vp (car (entsel "\nSelect Viewport...")))
    (setq vpscl (/ (cdr (assoc 45 (entget vp))) (cdr (assoc 41 (entget vp)))))
     
    kendresen, Apr 27, 2004
    #4
  5. Hanksor

    Jeff Mishler Guest

    This will work with normal & polygonal viewports....

    (defun getvpscale (/ ent elist vpscale)
    (setq ent (car (entsel "\nSelect viewport: ")))
    (if ent
    (progn
    (setq elist (entget ent))
    (cond ((= (cdr (assoc 0 elist)) "VIEWPORT") t)
    ((and (= (cdr (assoc 0 elist)) "LWPOLYLINE")
    (assoc 330 elist))
    (setq elist (entget (cdr (assoc 330 elist)))))
    (t (princ "\nNot a valid viewport object....")(setq elist nil)))
    (if elist (setq vpscale (/ (cdr (assoc 45 elist)) (cdr (assoc 41
    elist)))))
    )
    )
    (if vpscale
    (princ (strcat "\nVpscale = " (rtos vpscale)))
    (princ "\nNothing selected.....")
    )
    (princ)
    )

    Jeff
     
    Jeff Mishler, Apr 27, 2004
    #5
  6. Hanksor

    jclaidler Guest

    Isn't this a bit easier ??

    (last (trans '(0 0 1) 3 2))
     
    jclaidler, Apr 27, 2004
    #6
  7. Yes! But only for an active viewport
     
    Jason Piercey, Apr 27, 2004
    #7
  8. oops.... not exactly....
     
    Jason Piercey, Apr 27, 2004
    #8
  9. Hanksor

    Hanksor Guest

    Thanks!! That is exactly what I was looking for. I needed to determine the
    current scale of the viewport when it became active.
     
    Hanksor, Apr 27, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.