ml只是出于好奇,你为什么不试试这个,它似乎是一个更好的主意,让它画一个pline而不是创建一个块,如果我正确地阅读你的帖子,无论如何尝试这对于你想做的事情来说都很好。
- ;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!
|