How to get psviewports - not paperspace itself

Discussion in 'AutoCAD' started by Mark Propst, Feb 12, 2004.

  1. Mark Propst

    Mark Propst Guest

    Hi all,
    trying to collect paperspace viewports without getting the "paperspace
    itself viewport"

    the traditional way is to use entget and filter for (69 . 1)
    but in wanting to move away from entget to active x methods, i'm trying to
    find a way to distinguish the paperspace viewport from 'real' viewports
    created by mview etc.
    I can't see any properties that would easily distinguish them.
    it seems that the last one in a selection set is always the paperspace
    itself
    (setq vpset(ssget"x"(list(cons 0 "viewport")(cons 410 thistab))))

    is that a reliable test?

    another way would be to trap for an error setting the viewporton property to
    :vlax-false which would be more certain than relying on acad to always
    return vports in a certain order but seems like a really messy workaround,
    having to save the state first and reset it for those viewports that didn't
    error.

    (defun GetVportsThisTab( / thisvplist vpset numset loop thisTab)
    (if(not(= "Model" (setq thistab(adcf-getvar(GetActiveDoc)"Ctab"))))
    (progn
    (setq loop 1)
    (setq vpset(ssget"x"(list(cons 0 "viewport")(cons 410 thistab))))
    (if vpset
    (progn
    (setq numset(sslength vpset))
    (forset vpset
    (lambda (vpent)
    (if(< loop numset)
    (progn
    (setq thisvplist(cons (Getobject vpent) thisvplist))
    )
    )
    (setq loop(1+ loop))
    );l
    );for
    );p
    );i
    );p
    );i
    thisVpList
    )

    tia
    Mark
     
    Mark Propst, Feb 12, 2004
    #1
  2. Mark Propst

    Jeff Mishler Guest

    Mark,
    I went about this by getting all the entities in the activespace and
    creating a list with all of the viewports. I then reverse the list and
    sabe the (cdr) of the list. This removes the first VP found which, as
    far as I can tell, is ALWAYS the first one in the database. (And it
    should be since it would need to be created the to be able to see the
    Layout prior to creating the other viewports...)
    Here's the portion of my code for that:

    (setq *activelayout* (vla-get-activelayout
    (vla-get-activedocument
    (vlax-get-acad-object))
    ))
    (setq layoutblk (vla-get-block *activelayout*))
    (vlax-for item layoutblk
    (if (= (vla-get-objectname item) "AcDbViewport")
    (setq layvp (cons item layvp))
    )
    )
    (setq layvp (cdr (reverse layvp))); remove the main PS view object

    HTH,
    Jeff
     
    Jeff Mishler, Feb 12, 2004
    #2
  3. Could you determine it based on the handles?

    <just guessing>
     
    Jason Piercey, Feb 12, 2004
    #3
  4. Mark Propst

    Kelie Guest

    That's how I have been doing it.

     
    Kelie, Feb 12, 2004
    #4
  5. Mark Propst

    Mark Propst Guest

    Hi Jeff,

    That sounds good.

    makes sense, also why the 69 code would always be 1.
    That's also why I thought it strange it was the last one in a selection set
    rather than the first one.
    the only argument against iterating everything in pspace is the theoretical
    efficiency of a filtered selection set as opposed to iterating all objects -
    though with todays speeds I doubt if it's detectable.

    my other thought is rather than trap for an error in setting display off
    would be trap for error in setting vport active - paperspace will bomb with
    that too.

    lots of ways to skin the cat maybe.

    Thanks for your input.
    Mark

    sonic.net...you aren't out in Sonoma county are you?
     
    Mark Propst, Feb 12, 2004
    #5
  6. Mark Propst

    Mark Propst Guest

    That's a clever thought too! As in the smallest handle would be the first
    created, therefore paperspace?

    You mean that cranium of yours has more than snow shoveling girls in it?
    :)
     
    Mark Propst, Feb 12, 2004
    #6
  7. Mark Propst

    Mark Propst Guest

    ok so another way...

    (defun GetRealPVports( tab / lst)
    (setq vpset(ssget"x"(list(cons 0 "VIEWPORT")(cons 410 tab))))
    (if vpset
    (progn
    (setq i 0)
    (if
    (null
    (vl-catch-all-error-p
    (setq res
    (vl-catch-all-apply
    'vlax-put-property
    (list *doc* 'mspace :vlax-true)
    )
    )
    )
    )
    (repeat i
    (setq vpent(ssname vpset i))
    (setq vpo(Vlax-ename->vla-object vpent))
    (and
    (null
    (vl-catch-all-error-p
    (setq res
    (vl-catch-all-apply
    'vlax-invoke-method
    (list vpo 'display :vlax-true)
    )
    )
    )
    )
    (null
    (vl-catch-all-error-p
    (setq res
    (vl-catch-all-apply
    'vlax-put-property
    (list *doc* 'activepviewport vpo)
    )
    )
    );catch
    );null
    (setq lst(cons vpo lst))
    );and;
    (setq i(1+ i))
    );repeat;
    );if
    );progn
    );if
    lst
    )

    but come to think of it, your way of iterating is probably better since you
    could also use it with dbx.
     
    Mark Propst, Feb 12, 2004
    #7
  8. That was my thought. Essentially the same concept
    as Jeff's, just a different route. As for my cranium,
    not much more :)
     
    Jason Piercey, Feb 12, 2004
    #8
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.