Viewport's attributes

Discussion in 'AutoCAD' started by biot023, Sep 30, 2004.

  1. biot023

    biot023 Guest

    Hallo - does anyone know a way that I can get the co-ordinates for the lower-left and upper-right corners of the viewport?
    Thanks in advance for any help,
    doug.
     
    biot023, Sep 30, 2004
    #1
  2. biot023

    Doug Broad Guest

    Lower left: center point - (half width, half height)
    Upper right: center point + (half width, half height)

    or you could use the getbounding box method.
     
    Doug Broad, Sep 30, 2004
    #2
  3. biot023

    biot023 Guest

    Hallo, & thanks for the reply -- would you be able to clarify for me?
    I cannot find any method for getting the center point in the references I have, nor any bounding box method.
    Sorry if I'm being dense -- how do I get these?
    & thanks for the response, again!
    doug.
     
    biot023, Oct 5, 2004
    #3
  4. biot023

    jcvhokstl Guest

    The description of your quest is not clear, so I assume you want the model space coordinates of the vport, not the paper space corners. This code will return all the points of a clipped viewport, too.

    Complications ensue if the ucs is different inside the viewport - this sets it to world and does not restore it. Also, if ucsfollow is on, the ucs is rotated, and the viewport is not locked, it rotates to world and zooms out, so watch it.

    (vl-load-com)

    (defun HOKSTLVportMSPoints
    (ent / elst vent vpbl vpur msbl msur lstPlinePoints intCtr lstIn lstPointsTrans lstPoints lstPointsFinal)
    (setq elst (entget ent)
    vent (vlax-ename->vla-object ent)
    )
    (if (/= 1 (logand 1 (cdr (assoc 90 elst)))) ; not perspective
    (progn (if (= 1 (getvar "cvport")) ; is the paper space viewport itself
    (command ".mspace")
    )
    (setvar "cvport" (cdr (assoc 69 elst))) ; necessary to get the trans to work correctly
    (if (cdr (assoc 345 elst))
    (command ".ucs" "r" (cdr (assoc 2 (entget (cdr (assoc 345 elst))))))
    (command ".ucs" "w")
    )
    (if (cdr (assoc 340 elst)) ; pline clip of viewport
    (progn (setq lstPlinePoints (vla-get-coordinates (vlax-ename->vla-object (cdr (assoc 340 elst))))
    lstPlinePoints (vlax-safearray->list (vlax-variant-value lstPlinePoints))
    intCtr 0
    )
    ; this list is not a list of lists of points, it is all strung in one list
    ; without each point being a list, just a pair of numbers, like
    ; (1.0 2.0 1.0 4.0 4.0 4.0 4.0 2.0)
    ; so we have to take the pairs and put them together into points
    (repeat (/ (length lstPlinePoints) 2)
    (setq lstPoints (cons (trans (list (nth intCtr lstPlinePoints) (nth (1+ intCtr) lstPlinePoints)) 3 2) lstPoints)
    intCtr (+ intCtr 2)
    )
    )
    (setq lstPointsTrans lstPoints)
    )
    (progn (vla-getboundingbox vent 'vpbl 'vpur)
    (setq msbl (trans (vlax-safearray->list vpbl) 3 2)
    msur (trans (vlax-safearray->list vpur) 3 2)
    )
    ; and this has to be done before translating from the dcs to the world
    (setq lstPointsTrans (list msbl (list (car msur) (cadr msbl)) msur (list (car msbl) (cadr msur))))
    )
    )
    )
    )
    (foreach lstIn lstPointsTrans
    (setq lstPointsFinal (cons (trans lstIn 2 0) lstPointsFinal))
    )
    lstPointsFinal
    )
     
    jcvhokstl, Oct 6, 2004
    #4
  5. biot023

    Doug Broad Guest

    Doug,
    Sorry. I just saw your response today so am assuming that you
    already have solved your problem. A good rule is to try to
    respond to those who answer your thread within a day. I usually
    pay attention for that length of time. Otherwise, responses
    may be ignored.

    Regards,
    Doug
     
    Doug Broad, Oct 18, 2004
    #5
  6. biot023

    biot023 Guest

    Yeah, sorry about that myself, man -- I've been on site a fair bit, lately -- no excuse for not minding your Ps & Qs, though.
    Thanks again, man.
    doug.
     
    biot023, Oct 19, 2004
    #6
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.