TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Adesu on August 04, 2008, 03:27:45 AM
-
I got problem to active one of 4 viewports, anyone have code? or please guide me
(defun c:test (/)
(command "_vports" 4 "")
; I want viewport upper left corner active how to set it
)
-
Hi
You go in modelspace to change cvport
@+
-
I FOUND THIS OUT BY ACCIDENT AND I WILL NEVER FORGET IT
CTRL-R TO CYCLE TRHOUGH THE VIEWPORTS
-
Hey, SKUI_BREAKER......
Well done mate...but did you really have to scream into my headphones with that revelation? I'm still trying to find my earpiece.........aha...found it........now, can I get back to normal? :lmao: :lmao:
-
SORRY BOUT THE CAPS I ALWAYS KEEP IT ON BY HABIT
-
(http://www.offthemarkcartoons.com/cartoons/2004-10-09.gif)
-
Try this:
(vla-put-mspace doc :vlax-true)
(setvar "cvport" vpid) ; CAB activate correct vp
Not a complete code so ask if you don't get it.
-
This will give you some more info.
Used to select two entity viewports.
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; + Viewport Select +
;;; + Created by C. Alan Butler +
;;; + Copyright 2005 +
;;; + by Precision Drafting & Design All Rights Reserved. +
;;; + Contact at ab2draft@TampaBay.rr.com +
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;; Returns the viewport entity name, ignoring second entities used when
;;; a non-standard viewport is created, circle, ellipse, LWpolyline
(defun vp_sel (/ vpflag sel-vport entvport vptest)
(if (= (getvar "TileMode") 1) ; in model space
;;------------------------------------------------
(progn
(alert "**** You must be in Paper Space to run this routine. ****")
)
;;------------------------------------------------
(progn ;else in a layout
(if (/= (getvar "cvport") 1)
(command "_.pspace") ; close the view port
)
(setq vpflag (getvar "cvport")) ; get viewport #
(while (= vpflag 1) ; No active viewport, Loop until one is picked
(setq sel-vport (car (entsel "\nSelect view port: ")))
(if (= sel-vport nil)
(alert
"You must select a viewport\r\n --=< Try again! >=--"
)
(progn
(setq entvport (entget sel-vport))
(if (and ;; not all vp objects are LWPolylines
;;(= (cdr (assoc 0 entvport)) "LWPOLYLINE")
(setq vptest (member '(102 . "{ACAD_REACTORS") entvport))
(setq vptest (member '(102 . "}") (reverse vptest)))
(assoc 330 vptest)
)
(setq entvport (entget (cdr (assoc 330 vptest))))
)
;; Make VP active
(if (= (cdr (assoc 0 entvport)) "VIEWPORT")
(progn
(setq vpflag (cdr (assoc 69 entvport)))
(command "mspace") ; activate the last vp active
(setvar "cvport" vpflag) ; switch to this vp
) ; endif viewport
)
)
) ; endif cond sel-vport
) ;endwhile (= vpFlag 1)
(command "_.pspace") ; close the view port
)
)
;; return the ename of vp or nil
(cond (entvport (cdr (assoc -1 entvport))))
)
-
Hi CAB,
I only change for one position(only for "UL"), but not for others, anyone know to find what wrong in my code.
(defun c:test (/ pos tm)
(setq tm (getvar "tilemode"))
(if
(= tm 1)
(setvar "tilemode" 0)
) ; if
(if
(/= (getvar "cvport") 1)
(command "_vports" 4 "")
)
(while
(setq pos (strcase (getstring "\nSelect VPORTS position[UL/LL/UR/LR]<UL>: ")))
(if (= pos "")(setq pos "UL"))
(cond
((= pos "UL")(setq pos 4))
((= pos "LL")(setq pos 5))
((= pos "UR")(setq pos 3))
((= pos "LR")(setq pos 6)))
(setvar "cvport" pos)
) ; while
(princ)
) ; defun
Try this:
(vla-put-mspace doc :vlax-true)
(setvar "cvport" vpid) ; CAB activate correct vp
Not a complete code so ask if you don't get it.
-
It works for me, but I think your viewport numbers are different.
You should try to find those numbers first:
(setq l (lastent))
(command "_vports" 4 "")
(setq vp1 (entnext l) vp2 (entnext vp1) vp3 (entnext vp2) vp4 (entnext vp3))
(setq vp1nr (cdr (assoc 69 (entget vp1))) posVP1 (cdr (assoc 10 (entget vp1))))
...
(defun LASTENT (/ E0 EN)
(setq E0 (entlast))
(while (setq EN (entnext E0))
(setq E0 EN)
)
E0
)