关于getpoint输入值和左键指定点
本帖最后由 SunSpring 于 2014-4-27 16:44 编辑如何区分getpoint的返回值是左键指定的点,还是输入距离后返回的点?
如果不能区分,可否写个自定义函数解决?用法最好和getpoint一样.
(defun c:cp (/ entgrp ept spt)
(prompt "按比例连续复制对象")
(if (setq entgrp (ssget))
(if (setq spt (getpoint "\n指定基准点:"))
(progn
(command ".copy" entgrp "" "m" spt)
(while (setq ept (mygetpoint spt "\n指定位移的第二点或 <用第一点作位移>:"))
(cond
((= (car ept) 5)
(command (cdr ept))
)
((= (car ept) 2)
(command (* (/ 1.0 (getvar "dimlfac")) (distance spt (cdr ept))))
)
)
)
(command "")
)
)
)
(princ)
)
(defun mygetpoint ( a b / c lastoldprompt)
(if (setq lastoldprompt (getvar "lastprompt")
c (getpoint a b)
)
(setq c (if (= (getvar "lastprompt") lastoldprompt)
(cons 5 c)
(cons 2 c)
)
)
)
c
) 本帖最后由 llsheng_73 于 2014-1-2 15:47 编辑
(defun mygetpoint(/ a b)
(setq a(grread)b(nth 1 a)
a(if(<(car a)3)
(list 2(read(strcat"("(VL-STRING-TRANSLATE",; "" "(strcat(chr b)(getstring(prompt(chr b)))))")")))a))
(if(/=(length(nth 1 a))3)(progn(PROMPT"点无效")(mygetpoint))a)
)
;;如果返回值 (5 (175.403 71.6869 0.0))是鼠标点击得到的坐标
;;如果返回值 (3 (175.403 71.6869 0.0))是鼠标点击得到的坐标
;;如果返回值 (2 (175.403 71.6869 0.0))是键盘输入得到的坐标
llsheng_73 发表于 2014-1-2 14:05 static/image/common/back.gif
这个方法有些缺陷,当开启极轴或捕捉时点下的点和光标点并不相同 SunSpring 发表于 2014-1-2 14:28 http://bbs.mjtd.com/static/image/common/back.gif
这个方法有些缺陷,当开启极轴或捕捉时点下的点和光标点并不相同
看样子只能想法专门写一个。。。 本帖最后由 llsheng_73 于 2014-1-4 17:15 编辑
(if(setq lastoldprompt(getvar"lastprompt")b(getpoint))(setq b(if(=(getvar"lastprompt")lastoldprompt)(cons 5 b)(cons 2 b))))
;;这样鼠标点击会返回(5 x y z)而键盘输入会返回(2 x y z),要用坐标得通过(cdr b)得到,而通过(car b)可以确定是键盘输入的还是鼠标点击的
;;如果直接右键会跟(GETPOINT)一样返回NIL llsheng_73 发表于 2014-1-4 17:05 static/image/common/back.gif
(if(setq lastoldprompt(getvar"lastprompt")b(getpoint))(setq b(if(=(getvar"lastprompt")lastoldprompt) ...
还是解决不了问题。我把我的程序贴上,你看看吧。 本帖最后由 xj6019 于 2019-12-1 18:50 编辑
谁在这基础上给我改改啊
(defun c:test ()
(CMDLA0)
(while (setq pt (getpoint "\n插入点<退出>"))
(command "insert" "xx" pt "" "" "")
(setq s1(entlast))
(SUB_UPD s1 41 1)
(SUB_UPD s1 42 1)
(SUB_UPD s1 43 1)
(command"explode" s1 "")
)
(CMDLA1)
)
xx为文件路径 不需要炸开 所有比例都是1就行不用旋转 命令之后啥都别调直接放入 哪位大神动动手搞搞啊
llsheng_73 发表于 2014-1-4 17:05
(if(setq lastoldprompt(getvar"lastprompt")b(getpoint))(setq b(if(=(getvar"lastprompt")lastoldprompt) ...
用空格 为什么跟回车或者右键 的结果不同呢?烦恼 llsheng_73 发表于 2014-1-4 17:05
(if(setq lastoldprompt(getvar"lastprompt")b(getpoint))(setq b(if(=(getvar"lastprompt")lastoldprompt) ...
改用vla-getpoint,可以解决空格输入的差异。
页:
[1]