- UID
- 1
- 积分
- 15892
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
ZOOM ALL ON ALL VIEWPORTS
Product AUTOCAD Author HAARMANS,GUIDO
Date 05-JAN-98 Document ID 2431
Expiration date Attachments
Keywords AUTOLISP; ZOOM
Developer Consulting Group technical solution. Autodesk confidential, for ADN members only. Please read the disclaimer
Question
I want to 'zoom all' in all viewports. How can I do it ?
Answer
You can easily achieve this by using the CVPORT system variable:
Type: Integer
Saved in: Drawing
Initial value: 2
Sets the identification number of the current viewport. You can change this
value, thereby changing the current viewport, if the following conditions are
met:
- The identification number you specify is that of an active viewport.
- A command in progress has not locked cursor movement to that viewport.
- Tablet mode is off.
The number of current viewports can be found out with the AutoLISP function
(vports) which returns something like:
((4 (0.0 0.5) (0.5 1.0)) (5 (0.0 0.0) (0.5 0.5)) (2 (0.5 0.0) (1.0 0.5)) (3
(0.5 0.5) (1.0 1.0)))
(setq nv (length (vports))) will give you the number of vports. If you have
four vports, they are numbered 2 to 5.
An AutoLISP routine to zoom in for all vports can look like this:
(defun c:zoomall ( / i nv)
(setq i 1) ;initialise counter
(setq nv (length (vports))) ;get number of vports
(repeat nv
(setq i (1+ i)) ;start counting vports at 2
(setvar "CVPORT" i) ;set vport
(command "_zoom" "all") ;zoom all
)
(princ)
)
This works for tilemode on or off but if you define vports within vports,
this will only "zoom all" for the vports within the current one.
If you want to do different operation for different viewports, examine what
information is in the list returned by (vports). This is from the AutoCAD
help file:
Each viewport descriptor is a list consisting of the viewport identification
number and the coordinates of the viewport's lower-left and upper-right
corners. If the AutoCAD system variable TILEMODE is set to 1 (on), the
returned list describes the viewport configuration created with the AutoCAD
VPORTS command. The corners of the viewports are expressed in values between
0.0 and 1.0, with (0.0, 0.0) representing the lower-left corner of the
display screen's graphics area, and (1.0, 1.0) the upper-right corner. If
TILEMODE is 0 (off), the returned list describes the viewport objects created
with the MVIEW command. The viewport object corners are expressed in paper
space coordinates. Viewport number 1 is always paper space when TILEMODE is
off.
For example, given a single-viewport configuration with TILEMODE on, the
vports function might return this:
((1 (0.0 0.0) (1.0 1.0)))
Similarly, given four equal-sized viewports located in the four corners of
the screen when TILEMODE is on, the vports function might return this:
( (5 (0.5 0.0) (1.0 0.5))
(2 (0.5 0.5) (1.0 1.0))
(3 (0.0 0.5) (0.5 1.0))
(4 (0.0 0.0) (0.5 0.5)) )
The current viewport's descriptor is always first in the list. In the
previous example, viewport number 5 is the current viewport. |
|