Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Paper Space Viewport seperation

9 REPLIES 9
Reply
Message 1 of 10
jmodglin
594 Views, 9 Replies

Paper Space Viewport seperation

I am trying to figure out how to seperate the difference between the paper space viewport which is required for a Paper Space Layout and the one which you make. Some of my routines won't work correctly without seperating them (i.e., Viewport Lock). Has anyone found out how to delineate the viewports made by a user and the Paper space viewports required for a PS Layout? Is what I am asking clear?? Joshua Modglin
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: jmodglin

Check assoc 69.


--
-Jason

Member of the Autodesk Discussion Forum Moderator Program


> I am trying to figure out how to seperate the difference between the paper
space viewport which is required for a Paper Space Layout and the one which
you make.
Message 3 of 10
jmodglin
in reply to: jmodglin

?? They are all coming as "0", except the last user created PViewport is "2" and last Layout PViewport is "1". Thus, I can get the last active User created PViewport but what if I want all the drawing's user created PViewports?? Thanks for the help. Joshua Modglin
Message 4 of 10
Anonymous
in reply to: jmodglin

(setq ss (ssget "x" '((0 . "VIEWPORT") (-4 . "/=") (69 . 1))))

As far as the zeros are concerned, the viewport id numbers are not set until
the layout has been set current. Maybe that is what is going on?

--
-Jason

Member of the Autodesk Discussion Forum Moderator Program


> ?? They are all coming as "0",
Message 5 of 10
jmodglin
in reply to: jmodglin

Interesting! (SETQ *DOC* (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT)))
(SETQ CURLAYOUT (VLA-GET-ACTIVELAYOUT *DOC*))
(SETQ LAYOUTS (VLA-GET-LAYOUTS *DOC*))
(SETQ CNT (VLA-GET-COUNT LAYOUTS))
(WHILE (> CNT 0)
(SETQ LAYOUT (VLA-ITEM LAYOUTS (- CNT 1)))
(IF (/= "Model" (VLA-GET-NAME LAYOUT))
(VLA-PUT-ACTIVELAYOUT *DOC* LAYOUT)
)
(SETQ CNT (- CNT 1))
)
(VLA-PUT-ACTIVELAYOUT *DOC* CURLAYOUT)
(SETQ SS (SSGET "X" (LIST (CONS 0 "VIEWPORT")(CONS -4 "<>")(CONS 69 1))))
Thanks for the info, Jason! Joshua Modglin
Message 6 of 10
Anonymous
in reply to: jmodglin

Your welcome. Not sure I follow what you are doing with all of that....

--
-Jason

Member of the Autodesk Discussion Forum Moderator Program


> Thanks for the info, Jason!
Message 7 of 10
jmodglin
in reply to: jmodglin

As you stated earlier, the layouts have to have been active during the current drawing session for the DXF code 69 to read correctly. All the jargin ahead of the "SSGET" guarantees that. Joshua Modglin
Message 8 of 10
Anonymous
in reply to: jmodglin

Unless you *have to* stick with ActiveX wouldn't this be easier?

(foreach x (layoutlist) (setvar "ctab" x))

or filter for what has been set current....

(mapcar
'(lambda (x) (if (not (JRP:LayoutActive x)) (setvar "ctab" x)))
(layoutlist)
)

; Argument: string, the name of a defined layout.
; Return: if the specified layout has been activated T
; is returned, otherwise nil.
; Notes:
; Viewport Id numbers are not assigned until 'that' space is set
; current. Since each layout is a viewport, the following would
; return T if the layout has been set current at least once.
(defun JRP:LayoutActive (Layout / ss)
(if
(setq
ss
(ssget
"x"
(list
'(0 . "VIEWPORT")
'(69 . 1)
(cons 410 Layout)
)
)
)
T
)
)

--
-Jason

Member of the Autodesk Discussion Forum Moderator Program


>All the jargin ahead of the "SSGET" guarantees that
Message 9 of 10
Anonymous
in reply to: jmodglin

I've been trying to find another way to filter the viewports, but the only thing
I can come up with is comparing the numeric values of the handles on the
assumption that the primary viewport is older than any created after within the
same layout, bu I don't know if that can be trusted. Anyone?

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ


"jmodglin" wrote in message
news:f0e3637.5@WebX.maYIadrTaRb...
> As you stated earlier, the layouts have to have been active during the current
drawing session for the DXF code 69 to read correctly. All the jargin ahead of
the "SSGET" guarantees that. Joshua Modglin
Message 10 of 10
wkiernan
in reply to: jmodglin

; LOCKVPS locks all viewports, UNLOCKVPS unlocks all viewports.
; Code derived from comment by jmodglin on Autodesk LISP forum
; http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Paper-Space-Viewport-seperation/m-p/8...

(defun-q C:LOCKVPS()
 (lockvp_sub "on")
 (princ "\nAll viewports locked. ")
 (prin1)
)

(defun-q C:UNLOCKVPS()
 (lockvp_sub "off")
 (princ "\nAll viewports unlocked. ")
 (prin1)
)

(defun-q lockvp_sub(arg)
 (setq oldcmd (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq *doc* (vla-get-activedocument (vlax-get-acad-object))
       curlayout (vla-get-activelayout *doc*)
       layouts (vla-get-layouts *doc*)
       cnt (vla-get-count layouts)
 )
 (while (> cnt 0)
  (setq layout (vla-item layouts (- cnt 1)))
  (if (/= "Model" (vla-get-name layout))
   (vla-put-activelayout *doc* layout)
  )
  (setq cnt (- cnt 1))
 )
 (vla-put-activelayout *doc* curlayout)
 (setq ss (ssget "x" (list (cons 0 "viewport")(cons -4 "<>")(cons 69 1)))
       ctab (getvar "ctab")
 )
 (foreach vpname (ss2enl ss)
  (setq vpdata (entget vpname))
  (setvar "ctab" (cdr (assoc 410 vpdata)))
  (command "mview" "lock" arg vpname "")
 )
 (setvar "ctab" ctab)
 (setvar "cmdecho" oldcmd)
)
------

1.) I prefer lower-case...

2.) This could be improved by checking the 16384 bit in the 90 group code to see if the viewport is already locked or unlocked as desired, in which case you wouldn't have to touch it, and then by sorting by ctab value so you'd only have to go to each layout tab once even if there were multiple viewports that needed to be changed in it.  But even as is it's going to be a nice time-saver for me.  THANKS!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost