AUTO CAD lisp循环跳出
;1.标注大地坐标.(defunc:ZBB()(setqTEXT_H(getvar"USERR1"))(setqREPLY(strcat"\nEntertextheigh...
;1.标注大地坐标.
(defun c:ZBB()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil) (setvar "USERR1" T_H) (setq T_H TEXT_H))
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:" ))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:" ))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2)) (progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0)))
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H)))
);end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
)
;End of ZBB().
这个程序每次运行都要输入字高,不适合连续标注。我再获取第一点坐标的语句前加了一个repeat语句,但是不能中途退出,如果添加
(if (= p1 "")
(exit)
)
他会提示p1点数据格式不对,应该如何修改啊?
其实字高为题不大,这个程序本身是一次使用的,每次使用后都要从新启用,如果加了循环问题就不大了。
楼下的可不可以说明白点,就是使用while函数,也一样要判断,然后退出的,p1总是会得到一个非点坐标的值,还是会报告错误的。 展开
(defun c:ZBB()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil) (setvar "USERR1" T_H) (setq T_H TEXT_H))
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:" ))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:" ))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2)) (progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0)))
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H)))
);end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
)
;End of ZBB().
这个程序每次运行都要输入字高,不适合连续标注。我再获取第一点坐标的语句前加了一个repeat语句,但是不能中途退出,如果添加
(if (= p1 "")
(exit)
)
他会提示p1点数据格式不对,应该如何修改啊?
其实字高为题不大,这个程序本身是一次使用的,每次使用后都要从新启用,如果加了循环问题就不大了。
楼下的可不可以说明白点,就是使用while函数,也一样要判断,然后退出的,p1总是会得到一个非点坐标的值,还是会报告错误的。 展开
展开全部
标注大地坐标.
(defun c:ZBB()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil) (setvar "USERR1" T_H) (setq T_H TEXT_H))
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:" ))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:" ))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2)) (progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0)))
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H)))
);end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
)
;End of ZBB().
这个程序每次运行都要输入字高,不适合连续标注。我再获取第一点坐标的语句前加了一个repeat语句,但是不能中途退出,如果添加
(if (= p1 "")
(exit)
)
他会提示p1点数据格式不对,应该如何修改啊?其实字高为题不大,这个程序本身是一次使用的,每次使用后都要从新启用,如果加了循环问题就不大了。
楼下的可不可以说明白点,就是使用while函数,也一样要判断,然后退出的,p1总是会得到一个非点坐标的值,还是会报告错误的。
或者这一段
字高你用一个默认的就行了,
试试下面这个代码
(setq h (ureal 1 "" "\n文字高度:" 5))
如果循环的话需要 while 函数的
=========================================
(defun c:ZBB ()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil)
(setvar "USERR1" T_H)
(setq T_H TEXT_H)
)
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:"))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:"))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2))
(progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0))
)
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H))
)
) ;end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
(c:zbb)
)
这个可以循环的,就是每次都提示字高,你可以用两个程序:一个用来设置字高存入系统里,另一个直接读取系统已存的字高用来标注
(defun c:ZBB()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil) (setvar "USERR1" T_H) (setq T_H TEXT_H))
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:" ))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:" ))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2)) (progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0)))
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H)))
);end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
)
;End of ZBB().
这个程序每次运行都要输入字高,不适合连续标注。我再获取第一点坐标的语句前加了一个repeat语句,但是不能中途退出,如果添加
(if (= p1 "")
(exit)
)
他会提示p1点数据格式不对,应该如何修改啊?其实字高为题不大,这个程序本身是一次使用的,每次使用后都要从新启用,如果加了循环问题就不大了。
楼下的可不可以说明白点,就是使用while函数,也一样要判断,然后退出的,p1总是会得到一个非点坐标的值,还是会报告错误的。
或者这一段
字高你用一个默认的就行了,
试试下面这个代码
(setq h (ureal 1 "" "\n文字高度:" 5))
如果循环的话需要 while 函数的
=========================================
(defun c:ZBB ()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil)
(setvar "USERR1" T_H)
(setq T_H TEXT_H)
)
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:"))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:"))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2))
(progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0))
)
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H))
)
) ;end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
(c:zbb)
)
这个可以循环的,就是每次都提示字高,你可以用两个程序:一个用来设置字高存入系统里,另一个直接读取系统已存的字高用来标注
展开全部
字高你用一个默认的就行了,
试试下面这个代码
(setq h (ureal 1 "" "\n文字高度:" 5))
如果循环的话需要 while 函数的
=========================================
(defun c:ZBB ()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil)
(setvar "USERR1" T_H)
(setq T_H TEXT_H)
)
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:"))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:"))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2))
(progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0))
)
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H))
)
) ;end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
(c:zbb)
)
这个可以循环的,就是每次都提示字高,你可以用两个程序:一个用来设置字高存入系统里,另一个直接读取系统已存的字高用来标注
试试下面这个代码
(setq h (ureal 1 "" "\n文字高度:" 5))
如果循环的话需要 while 函数的
=========================================
(defun c:ZBB ()
(setq TEXT_H (getvar "USERR1"))
(setq REPLY (strcat "\nEnter text height <" (rtos TEXT_H 2 3) ">:"))
(setq T_H (getreal REPLY))
(if (/= T_H nil)
(setvar "USERR1" T_H)
(setq T_H TEXT_H)
)
(setvar "OSMODE" 32)
(setq p1 (getpoint "\nint-point:"))
(setvar "OSMODE" 0)
(setq n1 (nth 1 p1))
(setq e1 (nth 0 p1))
(setq nn (rtos n1 2 3))
(setq ee (rtos e1 2 3))
(setq nn (strcat "X_" nn))
(setq ee (STRCAT "Y_" ee))
(setq p2 (getpoint "\nsecond point:"))
(setq fw (angle p1 p2))
(setq fw1 (/ pi 2))
(setq fw2 (/ (* pi 3) 2))
(if (and (> fw fw1) (< fw fw2))
(progn
(setq pe (polar p2 (* pi -1) (* 7.5 T_H)))
(setq pt (polar pe 0 0))
)
;else------------------------
(progn
(setq pe (polar p2 0 (* 7.5 T_H)))
(setq pt (polar p2 0 T_H))
)
) ;end if----------------------------
(setq p3 (polar pt fw1 (* T_H 0.5)))
(COMMAND "text" p3 T_H "0" nn)
(setq p3 (polar pt fw2 (* T_H 1.5)))
(command "text" p3 T_H "0" ee)
(command "pline" p1 p2 pe "")
(setvar "osmode" 35)
(c:zbb)
)
这个可以循环的,就是每次都提示字高,你可以用两个程序:一个用来设置字高存入系统里,另一个直接读取系统已存的字高用来标注
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询