current viewport question

Discussion in 'AutoCAD' started by Phil, Apr 28, 2004.

  1. Phil

    Phil Guest

    Hi all,

    When the user is on a paperspace layout in model view. How is the
    current viewport accessed.

    I plan on getting the scale properties and select all the modelspace
    objects in the viewport.
    I may be able to figure this out but I am lost on my first step of
    getting this viewport info.

    I would like to use only autolisp not vlisp or activex code.
     
    Phil, Apr 28, 2004
    #1
  2. Phil

    John Uhden Guest

    You should really get into ActiveX. Lack of doing so would be akin to limiting
    your vocabulary to words with two or fewer syllables.

    For a start (ActiveX or not), checkout the CVPORT variable. It can be 1 only if
    the paperspace viewport is current.

    What do mean by "all the modelspace objects in the viewport?" All the
    modelspace objects are in modelspace '(410 . "Model").
     
    John Uhden, Apr 29, 2004
    #2
  3. Phil

    Phil Guest

    once I get the viewport I will simply select objects within the viewport
    limits.

    If there is another way let me know, but I just need to get the active
    viewport of the layout.

    I suspect there will be no active viewport when paperspace is active for
    the layout, correct?

    Thanks
     
    Phil, Apr 29, 2004
    #3
  4. Phil

    Phil Guest

    Let me reword. I'm at home away from my autocad to ask this question so
    I may not be saying it right.

    The user is in a layout tab other than model layout, the modelspace is
    active.

    I need to access the db of the current (active) viewport. In autolisp
    or dxf.

    I have been perusing Dietmar's autocad2000 book but can't seem to find
    the info on obtaining this info.

    Thanks
     
    Phil, Apr 29, 2004
    #4
  5. Phil

    Paul Turvill Guest

    (getvar "CVPORT") is a start ...
    ___
     
    Paul Turvill, Apr 29, 2004
    #5
  6. Phil

    Phil Guest

    I can't believe no one can help me on this one. I guess everyone
    familiar with the dxf codes are not helping on this ng anymore. I don't
    mind the half-a-day of digging on my own, its just I felt more
    comfortable getting the info from someone more experienced than I.

    Anyway, posting for review, after I researched some sample dxf files, It
    looks like I need to check tilemode to be sure the user is on paperspace
    and the the cvport has to be above 1, 1 being the viewport of the
    layout. Then I can match the viewport with the 69 code equal to the
    cvport. I believe there are codes in that entity to get the center
    point in the modelspace as well as the view extents etc. It appears to
    be all contained in that entity.

    If anyone who is familiar with this take has anything to add let me
    know, otherwise I figure its posted for future searches.

    Thank goodness I have Dietmar's book on autocad 2000 objects since this
    newsgroup hasn't been too helpful.
     
    Phil, Apr 30, 2004
    #6
  7. Phil

    Jeff Mishler Guest

    Really? Did you try to let it help you? Did you do a search? I just did and
    returned 952 messages that have "Viewport" in the header. I can't believe
    that at least 1 of these doesn't have something that you are looking
    for.........

    Love to help, but I wasn't too clear as to what it is you are trying to
    accomplish.

    I thought John Uhden gave you the best advise you're going to get: "You
    should really get into ActiveX. Lack of doing so would be akin to limiting
    your vocabulary to words with two or fewer syllables."

    Good luck and if you can ask a specific question on where you are stuck I'll
    do my best to answer it.

    Jeff
     
    Jeff Mishler, Apr 30, 2004
    #7
  8. Phil

    John Uhden Guest

    Ah, you have the ideas, but seem to be reluctant to attempt to employ them.
    Might I suggest trial and error as many of us here have skinned a knee or two.
    We might have a ready-made solution, or might create one and give it to you, but
    that's not the spirit here. Rather it is to guide you to your own solution,
    helping where you stumble, but not necessarily providing the transportation.

    It seems you want to use (ssget "C") or maybe (ssget "W") to acquire the
    entities within a rectangle, or in the case of an irregular viewport to use
    (ssget "CP") or (ssget "WP"). So you need to translate the viewport boundary to
    the territory it covers in ModelSpace. There are plenty of examples you can
    find to do such point transformations; you just have to watch out for non-world
    UCS's. As to selecting the viewport, that's really up to you. There may be
    none; there may be some frozen (yech); there may be some offscreen; there may be
    some deactivated by virtue of MAXACTVP being exceeded.

    If you can't find some decent leads via Google, then post what you are trying,
    and we'll try to guide you.
     
    John Uhden, Apr 30, 2004
    #8
  9. Phil

    Phil Guest

    Thanks Jeff, your right about me not doing a search. I checked my
    autocad help file under cvport and didn't get much. Why I put so much
    faith in the helpfile is my fault. Plus, I have ACad at work not here
    at home, and I have the internet here at home not at work so.... But I
    will always post a question if I get stuck, thanks.

    You're right,this ng has been great, I should have tried a search first,
    I know well there's a wealth of info in the past posts here.
     
    Phil, Apr 30, 2004
    #9
  10. Phil

    Phil Guest

    Thanks John, but I really was trying to avoid asking for a whole
    routine, I love coding, I do it in my access Vb, here in Autocad, cpp
    utilities for windows and some pretty good old programs in c/dos.

    I was just stuck on what object had the info, and made a mistake in not
    trying a search. But I will look into your suggestions when I get that
    far.

    Thanks
     
    Phil, Apr 30, 2004
    #10
  11. Phil

    John Uhden Guest

    Excellent! Once you define your intended process, even if portions are what
    Doug calls "pseudo-code" we can all have fun helping to make it work right.
     
    John Uhden, Apr 30, 2004
    #11
  12. Phil

    Jeff Mishler Guest

    OK, that's better ;-)

    Now, here's a start for you if you'd be interested in using ActiveX to
    achieve your goal:

    (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
    (if (and (= 0 (getvar "tilemode"))
    (= :vlax-true (vla-get-mspace *doc*))
    )
    (progn
    (setq vp (vla-get-activepviewport *doc*))
    ; get your data for the viewport here....
    )
    )

    And with the vp that was set above you can use (vlax-dump-object vp t) which
    will show you which properties and methods are available for the vp object.

    Good Luck,
    Jeff
     
    Jeff Mishler, Apr 30, 2004
    #12
  13. Phil

    Jeff Mishler Guest

    arghhh********

    replace (getvar "tilemode") with (vla-get-activespace *doc*)

    From what I understand you shouldn't mix getvar/setvar with vl*-
    functions.....

    Jeff

     
    Jeff Mishler, Apr 30, 2004
    #13
  14. Phil

    Joe Burke Guest

    Phil,

    Sort of underlining what Jeff said. Do a Google search on this NG for VPRECT.LSP

    ;; VPRECT.LSP - Copyright ©1999 Tony Tanzillo
    ;; AutoCAD 2000 / Visual LISP sample application
    ;; Demonstrates how to transform a paper
    ;; space viewport's corner points into MS
    ;; world coordinate space.

    Joe Burke
     
    Joe Burke, May 1, 2004
    #14
  15. Phil

    Phil Guest

    I figured it out myself, thanks anyway, by inspecting the entities. I
    did a search and like I suspected my way was faster. I still don't
    think my question was that unclear but sorry if it was.

    Here's info if someone searches. Again, I am going from memory (short),
    so correct me if I got the numbers wrong.

    1. tilemode must be 0 for paperspace
    2. search entities for code 0 = "viewport" and cvport = code 69
    (haven't checked yet but assume 69 is unique for drawing and not
    layout)
    3. 10 and 12 are center points in MS and PS
    4. 45 is scale factor
     
    Phil, May 1, 2004
    #15
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.