smartstar 发表于 2012-5-5 16:01:41

快速建有比例的视口

本帖最后由 smartstar 于 2012-5-5 16:02 编辑

这个是我拿别人程序改的,希望对大家有用:


(defun c:VR      ()
(setvar "DYNMODE" 3)
(setvar "cmdecho" 0)
(setq LAY (getvar "CLAYER"))
(setq os (getvar "OSMODE"))
(setq olderr *error*)                        ;保存原有*erroer*函数内容
(defun *error* (msg)                        ;自定义出错处理
    (COMMAND "CLAYER" LAY)
    (setq *error* olderr)
    (princ errn)
)
(if (= scaa nil)
    (setq scaa "100")
)
(if (= 1 (getvar "TILEMODE"))
    (progn
      (setq err_old *error*
            *error* err_new
      ) ;_ end of setq
      (setvar "OSMODE" 0)
      (command "model")
      (princ "\n请点取需要出图范围第一角点:\n")
      (setq FP (getpoint))
      (setq SP (getcorner FP "\n请点取出图范围另一角点:\n"))
      (setq HT (abs (- (cadr sp) (cadr fp))))
      (setq WD (abs (- (car sp) (car fp))))
      (COMMAND "CLAYER" LAY)
      (setvar "OSMODE" os)
      (setq *error* olderr)                ;恢复原有*error*函数内容
      (COMMAND "CLAYER" LAY)
      (setvar "OSMODE" os)

      (setvar "TILEMODE" 0)

      (princ
      "\n\n\n★★注意:\n\n若现在不是您要创建视口的布局空间,请结束此命令,\n并手动切换至要要创建视口的布局重新运行本命令。\n\n"
      )
      (c:VR)
    )
    (progn
      (if (or (null fp) (null sp))
      (progn
          (alert "\n程序将切换至【模型空间】设置视口显示区域!")
          (princ
            "
      \n程序将切换至【模型空间】设置视口显示区域!"
          )
          (setvar "TILEMODE" 1)
          (c:VR)
      )
      (progn
          (command "PSPACE")
          (setq      sca
               (getstring
                   (strcat
                     "\n请输入出图比例【 1∶?】<"
                     scaa
                     ">:\n\n\n★★注意:\n\n若现在不是您要创建视口的布局空间,请结束此命令,\n并手动切换至要要创建视口的布局重新运行本命令。"
                   )
               )
          )
          (if (= sca "")
            (setq sca scaa)
          ) ;_ end of if
          (setq scaa sca)
          (setq scal (atoi (substr sca 1)))
          (princ "\n请点取图的左下角点\n\n")
          (setq BLP (getpoint))
          (setq      TRP (list (+ (car BLP) (/ Wd scal))
                        (+ (cadr BLP) (/ HT scal))
                        0
                  ) ;_ end of list
          ) ;_ end of setq
          (command "_zoom" BLP TRP)

          (command "_mview" BLP TRP)
          (command "_mspace")
          (command "_zoom" fp sp)
          (command "_zoom" (strcat "1/" sca "xp"))
          (command "_pspace")
          (command "_zoom" "e")
          (command "mview" "l" "on" "c" BLP TRP "")
          (COMMAND "LAYER" "M" "Defpoints" "C" "135" "" "")
          (command "change" BLP "" "p" "la" "Defpoints" "")
          (setq blp nil)
      )
      )
    )
)                                        ;end if

(COMMAND "CLAYER" LAY)
(setvar "OSMODE" os)
(setq *error* olderr)                        ;恢复原有*error*函数内容
(COMMAND "CLAYER" LAY)
(setvar "OSMODE" os)
(princ)
)

alexmai 发表于 2014-7-5 12:33:27

我是這樣解決的

;;;图纸空间比例
(DEFUN c:1x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/1xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:2x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/2xp")
(command "mview" "l" "on" "all" "")
(princ)
)


(DEFUN c:3x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/3xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:4x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/4xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:5x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/5xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:10x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/10xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:15x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/15xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:20x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/20xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:25x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/25xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:30x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/30xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:40x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/40xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:50x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/50xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:75x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/75xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:100x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/100xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:125x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/125xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:150x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/150xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:200x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/200xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:250x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/250xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:300x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/300xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:400x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/400xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:500x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/500xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:750x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/750xp")
(command "mview" "l" "on" "all" "")
(princ)
)

(DEFUN c:1000x ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(command "zoom" "1/1000xp")
(command "mview" "l" "on" "all" "")
(princ)
)

;;;图纸空间锁定视图
(DEFUN c:ml ()
(setvar "cmdecho" 0)
(command "mview" "l" "on" "all" "")
(princ)
)

;;;图纸空间解锁视图
(DEFUN c:mf ()
(setvar "cmdecho" 0)
(command "mview" "l" "off" "all" "")
(princ)
)

lixiangyu1025 发表于 2019-4-17 12:59:28

非常好                      用

wenlusong 发表于 2022-12-11 19:19:43

感谢作者的贡献,不知什么原因出现错误,感谢分享源码哦,顶顶顶

wowan1314 发表于 2012-5-5 16:19:26

谢谢分享。

zhengchuan 发表于 2012-5-5 18:37:17

谢谢分享。

T_T 发表于 2012-5-5 23:50:39

这个东东好用啊,拿来参考参考,谢谢

psdcdr 发表于 2012-5-7 09:20:17

感谢分享,



这个命令会默认打开F12这个功能,能否修改下,不执行打开这个命令?

yoyoho 发表于 2012-5-7 10:01:03

感谢smartstar 分享原码程序!

psdcdr 发表于 2012-5-7 14:27:48

F12是动态输入的快捷键,用dynmode控制

fdb2007 发表于 2012-5-7 16:31:53

谢谢楼主分享,学习了

vlisp2012 发表于 2012-5-7 19:13:49

很好的程序,多谢了!!!

xotoo 发表于 2012-5-8 12:21:43

这个程序对于布局的使用有一定的帮助
不过和图纸集还是不能更紧密的结合

ACAD的图纸集生成视口还是有点麻烦啊
不知道以后的版本会不会改进
页: [1] 2 3 4 5
查看完整版本: 快速建有比例的视口