PDA

View Full Version : Getting the block/space of an activated viewport



JaCAD
2013-06-28, 05:42 PM
Hey all,

If I want to (vla-add something to modelspace, I use (vla-get-modelspace DocObj).

If I want to (vla-add something to a paperspace layout, I use (vla-get-block (vla-get-activeLayout DocObj))


How do I (vla-add something to modelspace through a paperspace layout viewport?
I know that (getvar "CVPORT") returns an index for the current active viewport. If this is 1, and we're in Paperspace, then no viewport is active, else, I've got the viewport id.
How do I get the block/space to (vla-add things into that space?

Edit:
I've found (vla-get-activePViewport DocObj) which seems to return the object of the currently active viewport, but like the activelayout, i cannot (vla-add to it. Unlike the ActiveLayout, I cannot (vla-get-block it in order to find the space.

BlackBox
2013-06-28, 07:27 PM
(defun c:WhereAmI ()
(prompt
(strcat "\n** "
(if (= 1 (getvar 'tilemode))
"ModelSpace"
(if (= 1 (getvar 'cvport))
"PaperSpace"
"PViewport Active"
)
)
" ** "
)
)
(princ)
)


[Edit] - ... Or, if only testing for in/out of PViewport Active:



(if (< (getvar 'tilemode) 1 (getvar 'cvport))
;; pviewport active
)