找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 927|回复: 0

把所有的VIEWPORT都ZOOM ALL的方法...

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-1-22 12:35:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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.
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-26 09:11 , Processed in 0.163412 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表