kasra 发表于 2022-7-6 07:51:02

它如何检查是否存在

你好
是否有解决方案来确定一条线与一条长基线之间存在交点?????
我知道应该检查lwpline的所有实体是否与直线相交。但是,由于我是编程新手,很难一个接一个地获取LPline的实体。
请指导我如何逐一检查???
谢谢大家的关注。

Lee Mac 发表于 2022-7-6 08:02:52

试试这个:
 

;; Finds all Intersections between obj1 & obj2
;; Args: obj1,obj2
;; VLA-Objects with Intersectwith method available
;; Returns: List of Intersections (or nil)

(defun GetIntersections (obj1 obj2 / GroupByNum)
;; Lee Mac~16.04.10

(defun GroupByNum (lst num / rtn) (setq rtn nil)

   (if lst
   (cons (reverse
             (repeat num
               (progn
               (setq rtn (cons (car lst) rtn)
                     lst (cdr lst))
               rtn)))

         (GroupByNum lst num))))

(GroupByNum (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3))

 
 
测试功能:
 

(defun c:test (/ e1 e2)
(vl-load-com)

(if (apply (function and)
            (mapcar
            (function
                (lambda (str sym)
                  (set sym (car (entsel str)))))

            '("\nSelect First Object: " "\nSelect Second Object: ") '(e1 e2)))

   (print (apply (function GetIntersections)
               (mapcar (function vlax-ename->vla-object) (list e1 e2)))))

(princ))

Lee Mac 发表于 2022-7-6 08:09:11

另一个,对于选择集:
 

(defun Get_Inters (ss / GroupByNum i j obj1 obj2 iLst)
;; Lee Mac~19.01.10

(defun GroupByNum (lst num / rtn) (setq rtn nil)

   (if lst
   (cons (reverse
             (repeat num
               (progn
               (setq rtn (cons (car lst) rtn)
                     lst (cdr lst))
               rtn)))

         (GroupByNum lst num))))

(setq i (sslength ss))

(while (not (minusp (setq j (1- i) i (1- i))))
   (setq obj1 (vlax-ename->vla-object (ssname ss i)))

   (while (not (minusp (setq j (1- j))))
   (setq obj2 (vlax-ename->vla-object (ssname ss j)))

   (setq iLst (append iLst
                  (GroupByNUm
                  (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3)))))

iLst)

 
测试功能:
 

(defun c:test (/ ss x)
(vl-load-com)

(if (setq ss (ssget))
   (foreach x (Get_Inters ss)
   (command "_.point" "_non" x)))

(princ))

kasra 发表于 2022-7-6 08:16:34

嗨,亲爱的李。
我应该在我的例行程序中测试你的帖子。之后我会告诉你结果。
谢谢你的帮助。

kasra 发表于 2022-7-6 08:19:59

你好
我对这个Lisp命令有问题
(vlax调用obj1’与obj2 acExtendNone相交)
在图形中寻找两个彼此不相交的对象之间的交点,但如果我将一个拉伸到另一个,它可以找到该点。
用这个命令不可能找到要点吗?
谢谢你的帮助。

Lee Mac 发表于 2022-7-6 08:30:55

研究IntersectWith方法的扩展参数:
 

MSasu 发表于 2022-7-6 08:35:54

您应该将acExtendNone替换为acExtendBoth、acExtendThisEntity或AcextendTheEntity。

kasra 发表于 2022-7-6 08:43:06

非常感谢。
我找到了解决办法。
对于研究所有方法的所有选项,您有什么建议?

Lee Mac 发表于 2022-7-6 08:46:44

 
Visual LISP IDE帮助文档:
 
http://lee-mac.com/functioninfo.html

kasra 发表于 2022-7-6 08:54:56

好啊Thanx很多。
我会在有任何要求之前试试。
页: [1]
查看完整版本: 它如何检查是否存在