1个回答
2014-01-07 · 知道合伙人软件行家
关注
展开全部
(defun C:MJHF38 ( / #k ss #k1 &kw &kw1 i @p1 @p2)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setq #k 100 ss (ssadd) #k1 (getdist (strcat "\n请输入距离<" (rtos #k 2 2) ">")))
(if (= #k1 nil) (setq #k1 #k) )
(setq &kw (entsel "\n请选择多段线"))
(if (/= &kw nil)
(progn
(princ "请选择点")
(setq &kw (car &kw) &kw (vlax-ename->vla-object &kw) &kw1 (ssget '((0 . "POINT"))))
(if (/= &kw1 nil)
(progn
(setq i 0)
(repeat (sslength &kw1)
(setq %k (ssname &kw1 i) i (+ i 1) @p1 (cdr (assoc 10 (entget %k))) @p2 (vlax-curve-getclosestpointto &kw @p1) #k (distance @p1 @p2))
(if (<= #k #k1) (setq ss (ssadd %k ss)) )
)
)
)
)
)
(setq #k (sslength ss))
(if (= #k 0) (alert "\n没有符合条件的点") )
(if (/= #k 0)
(progn
(sssetfirst nil ss)
(pause)
)
)
(prin1)
);;根据距离选择点;命名为:《MJHF38》.lsp
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setq #k 100 ss (ssadd) #k1 (getdist (strcat "\n请输入距离<" (rtos #k 2 2) ">")))
(if (= #k1 nil) (setq #k1 #k) )
(setq &kw (entsel "\n请选择多段线"))
(if (/= &kw nil)
(progn
(princ "请选择点")
(setq &kw (car &kw) &kw (vlax-ename->vla-object &kw) &kw1 (ssget '((0 . "POINT"))))
(if (/= &kw1 nil)
(progn
(setq i 0)
(repeat (sslength &kw1)
(setq %k (ssname &kw1 i) i (+ i 1) @p1 (cdr (assoc 10 (entget %k))) @p2 (vlax-curve-getclosestpointto &kw @p1) #k (distance @p1 @p2))
(if (<= #k #k1) (setq ss (ssadd %k ss)) )
)
)
)
)
)
(setq #k (sslength ss))
(if (= #k 0) (alert "\n没有符合条件的点") )
(if (/= #k 0)
(progn
(sssetfirst nil ss)
(pause)
)
)
(prin1)
);;根据距离选择点;命名为:《MJHF38》.lsp
追问
请问距离能改为平面距离吗
追答
(setvar "cmdecho" 0) (setvar "blipmode" 0)
;;修改为:
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setvar "dimzin" 0)
同时这个:(if (<= #k #k1) (setq ss (ssadd %k ss)) )
;;修改为:
(setq @p3 (rtos (nth 2 @p1) 2 8))
(if (and (<= #k #k1) (= @p3 "0.00000000")) (setq ss (ssadd %k ss)) )
;;这样的话,在平面的点都会选择,Z轴线标高不在0的不会选择;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询