szx025 发表于 2022-9-30 08:35:25

如何获取直线与CIRCLE,LWPOLYLINE的交点

(setq ss (ssget "f" (list t1 t2) '((0 . "CIRCLE,LWPOLYLINE")))

请问,如何获取直线(t1-t2)与CIRCLE,LWPOLYLINE的交点

liuhe 发表于 2022-9-30 08:55:52

用这个函数

Gets the points where one object intersects another object in the drawing.

Signature

VBA : RetVal = object.IntersectWith(IntersectObject, ExtendOption)

VL : RetVal = (vla-IntersectWith object IntersectObject, ExtendOption)

(vla-IntersectWith obj1 obj2 acExtendBoth)

Object : All Drawing Objects (Except Pviewport and PolygonMesh)
The object or objects this method applies to.

IntersectObject : Object, input-only;
The object can be one of All Drawing Objects.


ExtendOption : AcExtendOption enum; input-only
This option specifies if one or the other, both, or none of the entities are to be extended in order to attempt an intersection.


acExtendNone
Does not extend either object.

acExtendThisEntity
Extends the base object.

acExtendOtherEntity
Extends the object passed as an argument.

acExtendBoth
Extends both objects.




RetVal : Variant (array of doubles)
The array of points where one object intersects another object in the drawing.

Remarks

If the two objects do not intersect, no data is returned. You can request the point of intersection that would occur if one or both of the objects were extended to meet the other.

Example :


(defun c:al-intersectwith ()

(vl-load-com)

(setq util (vla-get-utility
                   (vla-get-activedocument
                        (vlax-get-acad-object))))
                        
(vla-getentity util 'obj1 'ip "\nSelect First Object: ")

(vla-getentity util 'obj2 'ip "\nSelect Second Object: ")

(setq int (vla-IntersectWith obj1 obj2 acExtendBoth))

(princ int)

(princ)

);defun




   

liuhe 发表于 2022-9-30 08:56:54

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=91172&highlight=%BD%BB%B5%E3%B2%E5%C8%EB%BF%E9

guosheyang 发表于 2022-9-30 20:28:54

循环求交点不就行了

飞雪神光 发表于 2022-10-1 01:00:41

(mapcar 'cadr (cdddr(car(ssnamex ss)))) 这个结果不准 精度不足 是函数的问题 不可避免
页: [1]
查看完整版本: 如何获取直线与CIRCLE,LWPOLYLINE的交点