模型框选区域转布局生成视口
本帖最后由 qmqyqj 于 2018-4-24 11:14 编辑这个程序是在本论坛上面找到了,具体忘记了了连接地址了贴出来想请教一下论坛前辈
1.这里面的出图比例怎么做记忆,使用一次后下次使用会记忆上次的出图比例并且能在提示里面显示出来?
2.这个代码在使用中有一个重复功能,当使用了一次后,如果在布局空间再使用这个功能,不能自动返回到模型空间重新选择区域,需要怎么修改?
本人大白,对lisp有点懵比,需求请高手指点下迷津!
defun c:wv ()
(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" 1)
(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
"2\n\n\n★★注意:\n\n若现在不是您要创建视口的布局空间,请结束此命令,\n并手动切换至要要创建视口的布局重新运行本命令。\n\n"
)
(c:wv)
)
(progn
(if (or (null fp) (null sp))
(progn
(princ "\n程序将切换至【模型空间】设置视口显示区域!")
(setvar "TILEMODE" 1)
(c:wv)
)
(progn
(setq sca
(getstring
(strcat
"\n空格重复上次比例,或输入新出图比例【 1∶?】>1:"
)
)
)
(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" "8" "" "")
(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)
) qmqyqj 发表于 2018-4-26 09:02
想问下,这执行完毕后,怎么自动的把那个框选的值清空(第一次在使用的时候,如果在布局空间,程序会自动 ...
如果您每次都是新的模式 可以把一些判斷關閉
defun c:wv ()
(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" 1)
(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
;"2\n\n\n★★注意:\n\n若现在不是您要创建视口的布局空间,请结束此命令,\n并手动切换至要要创建视口的布局重新运行本命令。\n\n"
;)
;(c:wv)
;)
;(progn
;(if (or (null fp) (null sp))
;(progn
; (princ "\n程序将切换至【模型空间】设置视口显示区域!")
; (setvar "TILEMODE" 1)
; (c:wv)
; )
; (progn
(setq sca
(getstring
(strcat
"\n空格重複上次比例,或輸入新出圖比例【 1︰" scaa "】>1:"
)
)
)
(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" "8" "" "")
(command "change" BLP "" "p" "la" "Defpoints" "")
(setq blp nil)
; )
;)
;)
;) ;end if
; (command "model")
(COMMAND "CLAYER" LAY)
(setvar "OSMODE" os)
(setq *error* olderr) ;恢复原有*error*函数内容
(COMMAND "CLAYER" LAY)
(setvar "OSMODE" os)
(princ)
) defun c:wv ()
(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" 1)
(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
"2\n\n\n★★注意:\n\n若现在不是您要创建视口的布局空间,请结束此命令,\n并手动切换至要要创建视口的布局重新运行本命令。\n\n"
)
(c:wv)
)
(progn
(if (or (null fp) (null sp))
(progn
(princ "\n程序将切换至【模型空间】设置视口显示区域!")
(setvar "TILEMODE" 1)
(c:wv)
)
(progn
(setq sca
(getstring
(strcat
"\n空格重複上次比例,或輸入新出圖比例【 1︰" scaa "】>1:"
)
)
)
(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" "8" "" "")
(command "change" BLP "" "p" "la" "Defpoints" "")
(setq blp nil)
)
)
)
) ;end if
(command "model")
(COMMAND "CLAYER" LAY)
(setvar "OSMODE" os)
(setq *error* olderr) ;恢复原有*error*函数内容
(COMMAND "CLAYER" LAY)
(setvar "OSMODE" os)
(princ)
) bssurvey 发表于 2018-4-24 15:20
如果是這樣,(command "model") 就沒作用了, 直接用手動切換比較快
想问下,这执行完毕后,怎么自动的把那个框选的值清空(第一次在使用的时候,如果在布局空间,程序会自动跳到模型空间,但使用了一次后在布局空间就不能自动跳回模型空间了,应该是有了那个框选的范围值后,程序就默认使用这个值,而不跳回模型空间重新框选了) bssurvey 发表于 2018-4-24 13:46
谢谢,明白一点了,非常感谢
后面添加(command"model") ,运行命令后会直接返回到模型空间,怎么能改成按空格才返回去(命令结束后,等待下一步指示,按空格,返回模型空间重新选择区域,按esc取消操作) 本帖最后由 bssurvey 于 2018-4-24 15:37 编辑
qmqyqj 发表于 2018-4-24 14:19
谢谢,明白一点了,非常感谢
后面添加(command"model") ,运行命令后会直接返回到模型空间,怎么能改成 ...
如果是這樣,(command "model") 就沒作用了, 直接用手動切換比較快 bssurvey 发表于 2018-4-24 15:20
如果是這樣,(command "model") 就沒作用了, 直接用手動切換比較快
好的,谢谢你的耐心解惑,我再研究研究 bssurvey 发表于 2018-4-26 09:58
如果您每次都是新的模式 可以把一些判斷關閉
请点取图的左下角点
; 错误: 输入中含有多余的闭括号:Q:Q 学习了,就是不知道为什么,运行完一次命令后,捕捉全部消失,动态输入的设置也发生了变化 请问这是为什么啊 改变了某些变量后,没有恢复。