xiaolong1487 发表于 2014-9-16 12:32:59

怎么跳出PAUSE

(DEFUN C:HD1()    (prinC "线性标注")(command "_dimlinear" pause pause pause )(c:hd1))
(DEFUN C:HD2()    (prinC "线性标注")(command "_dimlinear" "" pause pause )(c:hd2))
(DEFUN C:DD1()    (prinC "直径标注") (command "_dimdiameter" pause pause (c:dd1)))
(DEFUN C:RD1()    (prinC "半径标注") (command "_dimradius" pause pause (c:rd1)))
(DEFUN C:AD1()    (prinC "标弧度") (command "_dimangular" pause pause pause (c:ad1)))
(DEFUN C:XD1()    (prinC "坐标标注")(command "_.dimordinate" pause pause)(c:xd1))

请教大师,就是想重复执行CAD自带的命令。按上面这样做的话,跳不出PAUSE,想执行下个命令就会有问题!


hnzkhyyl 发表于 2023-9-28 23:59:35

SunSpring 发表于 2014-9-16 16:34


这是的f变量起到了什么作用,没看懂

SunSpring 发表于 2014-9-16 12:43:01

给你个参考

(defun c:dor (/ bpt)
(prompt "创建坐标点标注")
(setvar "cmdecho" 0)
(while (setq bpt (getpoint "\n指定点坐标:"))
    (command ".dimordinate")
    (setvar "cmdecho" 1)
    (command bpt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

xiaolong1487 发表于 2014-9-16 12:43:26

像图中一样!

xiaolong1487 发表于 2014-9-16 13:46:29

本帖最后由 xiaolong1487 于 2014-9-16 14:10 编辑

SunSpring 发表于 2014-9-16 12:43 static/image/common/back.gif
给你个参考
谢谢 SunSpring

为什么我改成这样的话选多段线都要先两次呢(defun c:xd1 (/ pt)
(prompt "坐标标注")
(setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定点坐标:"))
    (command "_dimordinate")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:hd1 (/ pt)
(prompt "线性标注")
(setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定第一条尺寸界线原点:"))
    (command "_dimlinear")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:hdd (/ ent)
(prompt "线性标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择标注对象:"))
    (command "_dimlinear" "")
    (setvar "cmdecho" 1)
    (command ent)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:ld1 (/ pt)
(prompt "对齐标注")
(setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定第一条尺寸界线原点:"))
    (command "_dimaligned")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:ldd (/ ent)
(prompt "对齐标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择标注对象:"))
    (command "_dimaligned" "")
    (setvar "cmdecho" 1)
    (command ent)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:dd1 (/ ent)
(prompt "直径标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择圆弧或圆:"))
    (command "_dimdiameter")
    (setvar "cmdecho" 1)
    (command ent)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:rd1 (/ ent)
(prompt "半径标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择圆弧或圆:"))
    (command "_.dimradius")
    (setvar "cmdecho" 1)
    (command ent)
    (while (> (getvar "cmdactive" ) 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:ad1 (/ ent)
(prompt "弧度标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择圆弧、圆、直线:"))
    (command "_dimangular")
    (setvar "cmdecho" 1)
    (command ent)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

SunSpring 发表于 2014-9-16 14:19:42

xiaolong1487 发表于 2014-9-16 13:46 static/image/common/back.gif
谢谢 SunSpring

为什么我改成这样的话选多段线都要先两次呢

因为命令要的参数和传递的内容不同,改为(command (cadr ent))

xiaolong1487 发表于 2014-9-16 14:52:17

SunSpring 发表于 2014-9-16 14:19 static/image/common/back.gif
因为命令要的参数和传递的内容不同,改为(command (cadr ent))

谢谢,已经改好了!(defun c:xd1 (/ pt)
(prompt "坐标标注")
(setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定点坐标:"))
    (command "_dimordinate")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:hd1 (/ pt)
(prompt "线性标注")
(setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定第一条尺寸界线原点:"))
    (command "_dimlinear")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:hdd (/ ent)
(prompt "线性标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择标注对象:"))
    (command "_dimlinear" "")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:ld1 (/ pt)
(prompt "对齐标注")
(setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定第一条尺寸界线原点:"))
    (command "_dimaligned")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:ldd (/ ent)
(prompt "对齐标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择标注对象:"))
    (command "_dimaligned" "")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:dd1 (/ ent)
(prompt "直径标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择圆弧或圆:"))
    (command "_dimdiameter")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:rd1 (/ ent)
(prompt "半径标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择圆弧或圆:"))
    (command "_.dimradius")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive" ) 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

(defun c:ad1 (/ ent)
(prompt "弧度标注")
(setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择圆弧、圆、直线:"))
    (command "_dimangular")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

琴剑江山_10184 发表于 2014-9-16 15:49:33

(defun c:df( / ge ent)
(setq ge (ssget "i"))
(if (= ge nil)
    (progn (setvar "cmdecho" 0)
(while (setq pt (getpoint "\n指定第一条尺寸界线原点:"))
    (command "_dimlinear")
    (setvar "cmdecho" 1)
    (command pt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
    (command "_.chprop" (entlast) "" "LA" "DIM" "")
);WHILE
      )
    (progn (setvar "cmdecho" 0)
(while (setq ent (entsel "\n选择标注对象:"))
    (command "_dimlinear" "")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
    (command "_.chprop" (entlast) "" "LA" "DIM" "")
);WHILE
      )
    )
    (princ)
)
在上面的程序再做了一下修改,把指定尺寸界线与选择对象整在一起了,分别以先择择对象,与不选择对象执行不同的标注。
最后把标注放到了DIM层

琴剑江山_10184 发表于 2014-9-16 16:07:54

(setq ge (ssget "i")) 高手再出手下,把这句改成判断按空格就完美了。
就与CAD一样了
指定第一条尺寸界线原点或 <选择对象>:

SunSpring 发表于 2014-9-16 16:34:09

本帖最后由 SunSpring 于 2014-9-16 16:46 编辑

琴剑江山_10184 发表于 2014-9-16 16:07 static/image/common/back.gif
(setq ge (ssget "i")) 高手再出手下,把这句改成判断按空格就完美了。
就与CAD一样了
指定第一条尺寸界线 ...
(defun c:dli ( / bpt ent f str)
(prompt "创建线性标注")
(setq f t)
(setq str "或 <选择对象>")
(while (setq bpt (getpoint (strcat "\n指定第一条尺寸界线原点" str ":")))
    (setq f nil)
    (setq str "")
    (command ".dimlinear")
    (setvar "cmdecho" 1)
    (command bpt)
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(while (and f (setq ent (entsel "\n选择标注对象:")))
    (command ".dimlinear" "")
    (setvar "cmdecho" 1)
    (command (cadr ent))
    (while (> (getvar "cmdactive") 0)
      (command pause)
    )
    (setvar "cmdecho" 0)
)
(princ)
)

琴剑江山_10184 发表于 2014-9-16 17:01:42

SunSpring 发表于 2014-9-16 16:34 static/image/common/back.gif


达到这样的效果了,感谢
请教T是什么意思,
页: [1] 2
查看完整版本: 怎么跳出PAUSE