CAD 二次开发 修改LISP
(defunc:dz(/oce1n1znh1sxh1p1)(vl-load-com)(setqoce1(getvar"cmdecho"))(setvar"cmdecho"...
(defun c:dz (/ oce1 n1 zn h1 sxh1 p1)
(vl-load-com)
(setq oce1 (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq ms (vla-get-modelspace
(vla-get-activedocument (vlax-get-acad-object))
)
)
(if qz
()
(setq qz "")
)
(if hz
()
(setq hz "")
)
(initget "c")
(setq nqz (getstring (strcat "\n请输入前缀<" qz ">/c(为空): " )))
(cond
((= nqz "c") (setq qz ""))
(T (if (/= nqz "")(setq qz nqz)))
)
(setq nhz (getstring (strcat "\n请输入后缀<" hz ">/c(为空): " )))
(cond
((= nhz "c") (setq hz ""))
(T (if (/= nhz "")(setq hz nhz)))
)
(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
(setq n1 1)
)
(if (not (setq zn (getint "\n请输入增加或减少的序数 <+1>: ")))
(setq zn 1)
)
(if (not (setq h1 (getreal "\n请指定文字高度 <2.5>: ")))
(setq h1 2.5)
)
(setq sxh1 (strcat qz (itoa n1) hz))
(setq p1 (getpoint "\n请指定插入点: "))
(while (/= p1 nil)
(setq p1 (vlax-3d-point p1))
(setq txt (vla-addtext
ms
sxh1
p1
h1
)
)
(setq
n1 (+ n1 zn)
sxh1 (strcat qz (itoa n1) hz)
p1 (getpoint "\n请指定下一插入点: ")
)
)
(setvar "cmdecho" oce1)
(vlax-release-object ms)
(princ)
)
他提示太多了。
我只要他提示:
输入前缀
输入起始编号,
输入字高
制定插入点就OK 展开
(vl-load-com)
(setq oce1 (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq ms (vla-get-modelspace
(vla-get-activedocument (vlax-get-acad-object))
)
)
(if qz
()
(setq qz "")
)
(if hz
()
(setq hz "")
)
(initget "c")
(setq nqz (getstring (strcat "\n请输入前缀<" qz ">/c(为空): " )))
(cond
((= nqz "c") (setq qz ""))
(T (if (/= nqz "")(setq qz nqz)))
)
(setq nhz (getstring (strcat "\n请输入后缀<" hz ">/c(为空): " )))
(cond
((= nhz "c") (setq hz ""))
(T (if (/= nhz "")(setq hz nhz)))
)
(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
(setq n1 1)
)
(if (not (setq zn (getint "\n请输入增加或减少的序数 <+1>: ")))
(setq zn 1)
)
(if (not (setq h1 (getreal "\n请指定文字高度 <2.5>: ")))
(setq h1 2.5)
)
(setq sxh1 (strcat qz (itoa n1) hz))
(setq p1 (getpoint "\n请指定插入点: "))
(while (/= p1 nil)
(setq p1 (vlax-3d-point p1))
(setq txt (vla-addtext
ms
sxh1
p1
h1
)
)
(setq
n1 (+ n1 zn)
sxh1 (strcat qz (itoa n1) hz)
p1 (getpoint "\n请指定下一插入点: ")
)
)
(setvar "cmdecho" oce1)
(vlax-release-object ms)
(princ)
)
他提示太多了。
我只要他提示:
输入前缀
输入起始编号,
输入字高
制定插入点就OK 展开
1个回答
展开全部
(defun c:dz (/ oce1 n1 zn h1 sxh1 p1)
(vl-load-com)
(setq oce1 (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq ms (vla-get-modelspace
(vla-get-activedocument (vlax-get-acad-object))
)
)
(if qz
()
(setq qz "")
)
(if hz
()
(setq hz "")
)
(initget "c")
(setq nqz (getstring (strcat "\n请输入前缀<" qz ">/c(为空): " )))
(cond
((= nqz "c") (setq qz ""))
(T (if (/= nqz "")(setq qz nqz)))
)
(setq hz "")
(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
(setq n1 1)
)
(setq zn 1)
(if (not (setq h1 (getreal "\n请指定文字高度 <2.5>: ")))
(setq h1 2.5)
)
(setq sxh1 (strcat qz (itoa n1) hz))
(setq p1 (getpoint "\n请指定插入点: "))
(while (/= p1 nil)
(setq p1 (vlax-3d-point p1))
(setq txt (vla-addtext
ms
sxh1
p1
h1
)
)
(setq
n1 (+ n1 zn)
sxh1 (strcat qz (itoa n1) hz)
p1 (getpoint "\n请指定下一插入点: ")
)
)
(setvar "cmdecho" oce1)
(vlax-release-object ms)
(princ)
)
(vl-load-com)
(setq oce1 (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq ms (vla-get-modelspace
(vla-get-activedocument (vlax-get-acad-object))
)
)
(if qz
()
(setq qz "")
)
(if hz
()
(setq hz "")
)
(initget "c")
(setq nqz (getstring (strcat "\n请输入前缀<" qz ">/c(为空): " )))
(cond
((= nqz "c") (setq qz ""))
(T (if (/= nqz "")(setq qz nqz)))
)
(setq hz "")
(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
(setq n1 1)
)
(setq zn 1)
(if (not (setq h1 (getreal "\n请指定文字高度 <2.5>: ")))
(setq h1 2.5)
)
(setq sxh1 (strcat qz (itoa n1) hz))
(setq p1 (getpoint "\n请指定插入点: "))
(while (/= p1 nil)
(setq p1 (vlax-3d-point p1))
(setq txt (vla-addtext
ms
sxh1
p1
h1
)
)
(setq
n1 (+ n1 zn)
sxh1 (strcat qz (itoa n1) hz)
p1 (getpoint "\n请指定下一插入点: ")
)
)
(setvar "cmdecho" oce1)
(vlax-release-object ms)
(princ)
)
追问
大师!!
能否再修改下,最后指定插入点, 你点击的位置是那段编号的中点,
例如"ZK-1" 文字出现在你点的地方的中间
还有就是输入的文字高度能否记忆上次输入的高度
谢谢!!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询