Current MSpace PViewport (not active) - Reactor question

Discussion in 'AutoCAD' started by James Allen, Nov 24, 2004.

  1. James Allen

    James Allen Guest

    Hi all, I'm stumped again. I have kludged two ways two determine which
    pviewport *would be* active if mspace is toggled, but neither is valid in my
    reactor and I keep thinking there ought to be a more direct way anyway. So,
    isn't there a more direct way to determine this? Kludges follow.

    Code:
    ;;; Kludge #1: Relatively beautiful :), but ssget + reactor = bad.
    (if (ssget "x" '((0 . "viewport") (68 . 2)))
    (vla-Item (vlax-get ActiveDocument 'ActiveSelectionSet) 0)
    )
    
    Code:
    ;;; Kludge #2: "If mspace is toggled."  HA!
    ;;; Unfortunately, toggling mspace is one of my reactor's triggers...
    (defun MWE:GetcPViewport (vp)
    (if (not (vl-catch-all-error-p
    (vl-catch-all-apply
    'vla-put-MSpace
    (list ActiveDocument :vlax-True)
    )
    )
    )
    (progn
    (setq vp (vla-get-ActivePViewport ActiveDocument))
    (vla-put-MSpace ActiveDocument :vlax-False)
    )
    )
    vp
    )
    
     
    James Allen, Nov 24, 2004
    #1
  2. James Allen

    LUCAS Guest

    ;;BY LUCAS
    ;;which pviewport *would be* active if mspace is toggled
    (defun GETCPVIEWPORT (/ LAYOUTNAME)
    (setq LAYOUTNAME
    (vla-get-name
    (vla-get-layout
    (vla-item
    (vla-get-blocks
    (vla-get-activedocument (vlax-get-acad-object))
    )
    "*PAPER_SPACE"
    )
    )
    )
    )
    (ssname (ssget "x"
    (list '(0 . "VIEWPORT") (cons 410 LAYOUTNAME) '(68 . 1))
    )
    0
    )
    )
     
    LUCAS, Nov 25, 2004
    #2
  3. James Allen

    James Allen Guest

    Thank you Lucas, but it won't work in this context (see kludge #1...).
    Selection set operations are not allowed in reactor functions.

    James


     
    James Allen, Nov 29, 2004
    #3
  4. James Allen

    Doug Broad Guest

    Hi James,
    What's the point? How would you use this info? What info
    do you need? (vla-object, handle, or viewport number)

    If just the viewport number, then use (vports)
    (cadr(vports)) = previous viewport number.
     
    Doug Broad, Nov 29, 2004
    #4
  5. James Allen

    James Allen Guest

    Hi Doug,

    Perhaps I should have included "Academic Excercise" in the long subject
    line. :), If that doesn't tell you all you need to know then...
    Sorry, guess I cut my code too short again. Multi-Level question:

    Level 1: Generally speaking, it seems like there would be a reactor
    compatible way to get the 'current' viewport (as described). I'm not seein'
    it.

    Level 2: Specifically, I'm trying to get the handle, which of course I can
    get if I have the vla-object. Thank you for the (vports) tip. I wasn't
    aware of that (or had forgotten). But I still don't know how to get to the
    handle w/o using a selection set. Actually, I think my main stump has to do
    with ActiveX. With the variety of ways to determine this via viewport
    numbers, I wonder why there is no viewport number ActiveX property or
    method? Or have I just overlooked it?

    Level 3: Why do I want this?
    1. A SS (System Set - e.g. Plumbing, Lighting, etc.) is stored; per
    viewport; via handle for multi-session use.
    2. A pull-down menu indicates the current SS via cvport sysvar reactor.
    3. In multi-viewport layouts, with pspace active, the 'current' viewport
    SS should be indicated in the menu and therefore has to be determined within
    the reactor.

    As you can see, this is pretty minor in the scheme of things. If the answer
    is no, as I think it is, I won't really be any worse off for it (perhaps
    better in fact). I mainly posted on the basis of 'levels' 1 and 2, out of
    curiosity. IOW, if anyone -just happens- to know, I'd be interested. But I
    don't want anyone spending a bunch of time trying to figure it out on my
    account.

    Thank you again Doug,

    James
     
    James Allen, Nov 29, 2004
    #5
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.