Author Topic: viewport limits routine help  (Read 2636 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
viewport limits routine help
« on: August 24, 2004, 03:43:43 PM »
hey guys i would like to modify this routine so it puts the box created on defpoints layer not the current layer. how do i modify this don't see anything about layers here but i'm not as sharp as you guys so....

Code: [Select]
;Tip1687:   VPLIM.LSP     Pspace Limits in Mspace (c)2001, Murray Clack
 
 ;VPLIM.lsp draws the limits of a Paperspace Viewport Boundary in MODELSPACE
 ;VP - Get ViewPort object
 ;HT - Get Outside HeighT of Viewport
 ;WD - Get Oustide WiDth of Viewport
 ;VN - Get Viewport Number
 ;CTR - Get CenTeR of Viewport
 ;CTRX - Caluculate X of Viewport CenTeR
 ;CTRY - Caluculate Y of Viewport CenTeR
 ;VS - Get View Size of viewport
 ;XP - Calculate XP factor of viewport
 ;IW - Calculate Width of viewport
 ;BL - Calculate Bottom Left corner of viewport
 ;BR - Calculate Bottom Right corner of viewport
 ;TR - Calculate Top Right corner of viewport
 ;TL - Calculate Top Left corner of viewport
 ;PW - Save PlineWid
 ;OS - Save OSmode



 ;start function and define variables
(defun
     C:VPL (/ VP HT WD VN CTR CTRX CTRY VS XP IW BL BR TR TL PW OS
           )

 ;turn off command echoing
  (setvar "cmdecho" 0)

 ;enter pspace
  (command ".pspace")

 ;select viewport boundary
  (setq VP
         (entget
           (car (entsel
                  "\nSelect Viewport to Draw Boundary
             in "
                ) ;_ end of entsel
           ) ;_ end of car
         ) ;_ end of entget
  ) ;_ end of setq

 ;Get Viewport height with
  (setq HT (cdr (assoc 41 VP)))

 ;Get Viewport width with
  (setq WD (cdr (assoc 40 VP)))

 ;Get Viewport Number
  (setq VN (cdr (assoc 69 VP)))

 ;enter mspace
  (command ".mspace")

 ;set correct viewport
  (setvar "cvport" VN)

 ;set UCS to View
  (command ".ucs" "v")

 ;Get VIEWCTR store as CTR
  (setq CTR (getvar "viewctr"))

 ;Get X of CTR
  (setq CTRX (car CTR))

 ;Get Y of CTR
  (setq CTRY (cadr CTR))

 ;Get inside Viewport height
  (setq VS (getvar "viewsize"))

 ;Get XP Factor with HeighT / View Size
  (setq XP (/ HT VS))

 ;Get inside width of Viewport by
  (setq IW (* (/ VS HT) WD))

 ;Find four corners of Viewport
  (setq BL (list (- CTRX (/ IW 2)) (- CTRY (/ VS 2))))

  (setq BR (list (+ CTRX (/ IW 2)) (- CTRY (/ VS 2))))

  (setq TR (list (+ CTRX (/ IW 2)) (+ CTRY (/ VS 2))))

  (setq TL (list (- CTRX (/ IW 2)) (+ CTRY (/ VS 2))))

 ;Save current pline width
  (setq PW (getvar "plinewid"))

 ;Set Pline width to zero
  (setvar "plinewid" 0)

 ;Save current osmode
  (setq OS (getvar "osmode"))

 ;Draw pline inside border
  (command ".pline" BL BR TR TL "c")

 ;Restore pline width back
  (setvar "plinewid" PW)

 ;Restore UCS back
  (command ".ucs" "p")

 ;Restore osmode
  (setvar "osmode" OS)

 ;Clean up command prompt
  (princ)

 ;Go Back To Papserspace
  (command ".pspace")

) ;The End!

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
viewport limits routine help
« Reply #1 on: August 24, 2004, 03:48:33 PM »
right after this
Code: [Select]

;turn off command echoing
  (setvar "cmdecho" 0)

put this
Code: [Select]

(command "_.layer" "m" "Defpoints" "")


does that work?
TheSwamp.org  (serving the CAD community since 2003)

ELOQUINTET

  • Guest
viewport limits routine help
« Reply #2 on: August 24, 2004, 04:22:14 PM »
hmm sorta but it keeps me in defpoints which could be dangerous how do i get it to revert to layer previous

ronjonp

  • Needs a day job
  • Posts: 7529
viewport limits routine help
« Reply #3 on: August 24, 2004, 04:59:12 PM »
try this:

Code: [Select]
;Tip1687:   VPLIM.LSP     Pspace Limits in Mspace (c)2001, Murray Clack

;VPLIM.lsp draws the limits of a Paperspace Viewport Boundary in MODELSPACE
;VP - Get ViewPort object
;HT - Get Outside HeighT of Viewport
;WD - Get Oustide WiDth of Viewport
;VN - Get Viewport Number
;CTR - Get CenTeR of Viewport
;CTRX - Caluculate X of Viewport CenTeR
;CTRY - Caluculate Y of Viewport CenTeR
;VS - Get View Size of viewport
;XP - Calculate XP factor of viewport
;IW - Calculate Width of viewport
;BL - Calculate Bottom Left corner of viewport
;BR - Calculate Bottom Right corner of viewport
;TR - Calculate Top Right corner of viewport
;TL - Calculate Top Left corner of viewport
;PW - Save PlineWid
;OS - Save OSmode



;start function and define variables
(defun
 C:VPL
      (/ VP HT WD VN CTR CTRX CTRY VS XP IW BL BR TR TL PW OS)

;turn off command echoing
  (setvar "cmdecho" 0)

;save current layer as "clay"
  (setq clay (getvar 'clayer))

;make current layer defpoints
  (command "_.layer" "m" "Defpoints" "")

;enter pspace
  (command ".pspace")

;select viewport boundary
  (setq VP
(entget
  (car
    (entsel
      "\nSelect Viewport to Draw Boundary
             in "
    ) ;_ end of entsel
  ) ;_ end of car
) ;_ end of entget
  ) ;_ end of setq

;Get Viewport height with
  (setq HT (cdr (assoc 41 VP)))

;Get Viewport width with
  (setq WD (cdr (assoc 40 VP)))

;Get Viewport Number
  (setq VN (cdr (assoc 69 VP)))

;enter mspace
  (command ".mspace")

;set correct viewport
  (setvar "cvport" VN)

;set UCS to View
  (command ".ucs" "v")

;Get VIEWCTR store as CTR
  (setq CTR (getvar "viewctr"))

;Get X of CTR
  (setq CTRX (car CTR))

;Get Y of CTR
  (setq CTRY (cadr CTR))

;Get inside Viewport height
  (setq VS (getvar "viewsize"))

;Get XP Factor with HeighT / View Size
  (setq XP (/ HT VS))

;Get inside width of Viewport by
  (setq IW (* (/ VS HT) WD))

;Find four corners of Viewport
  (setq BL (list (- CTRX (/ IW 2)) (- CTRY (/ VS 2))))

  (setq BR (list (+ CTRX (/ IW 2)) (- CTRY (/ VS 2))))

  (setq TR (list (+ CTRX (/ IW 2)) (+ CTRY (/ VS 2))))

  (setq TL (list (- CTRX (/ IW 2)) (+ CTRY (/ VS 2))))

;Save current pline width
  (setq PW (getvar "plinewid"))

;Set Pline width to zero
  (setvar "plinewid" 0)

;Save current osmode
  (setq OS (getvar "osmode"))

;Draw pline inside border
  (command ".pline" BL BR TR TL "c")

;Restore pline width back
  (setvar "plinewid" PW)

;Restore UCS back
  (command ".ucs" "p")

;Restore osmode
  (setvar "osmode" OS)

;Restore curernt layer
  (setvar "clayer" clay)

;Clean up command prompt
  (princ)

;Go Back To Papserspace
  (command ".pspace")

) ;The End!

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
viewport limits routine help
« Reply #4 on: August 24, 2004, 05:15:10 PM »
Quote from: eloquintet
hmm sorta but it keeps me in defpoints which could be dangerous how do i get it to revert to layer previous

come on Dan.............. you ain't trying very hard. There is enough code on layer manipulation in this place to choke a horse. Read man read........... :D
TheSwamp.org  (serving the CAD community since 2003)