在实体相交判断中的问题
<p>请教高手,实体有无交点能不能判断?应该怎么判断?</p><p>能不能用IntersectWith命令判断?</p><p>请高手指点</p><p>如果不能的话有没有办法自己编程实现?</p> <p>Sub Example_IntersectWith()<br/> ' This example creates a line and circle and finds the points at<br/> ' which they intersect.<br/> <br/> ' Create the line<br/> Dim lineObj As AcadLine<br/> Dim startPt(0 To 2) As Double<br/> Dim endPt(0 To 2) As Double<br/> startPt(0) = 1: startPt(1) = 1: startPt(2) = 0<br/> endPt(0) = 5: endPt(1) = 5: endPt(2) = 0<br/> Set lineObj = ThisDrawing.ModelSpace.AddLine(startPt, endPt)<br/> <br/> ' Create the circle<br/> Dim circleObj As AcadCircle<br/> Dim centerPt(0 To 2) As Double<br/> Dim radius As Double<br/> centerPt(0) = 8: centerPt(1) = 8: centerPt(2) = 0<br/> radius = 1<br/> Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius)<br/> ZoomAll<br/> <br/> ' Find the intersection points between the line and the circle<br/> Dim intPoints As Variant<br/> intPoints = lineObj.IntersectWith(circleObj, acExtendNone)<br/> <br/> ' Print all the intersection points<br/> Dim I As Integer, j As Integer, k As Integer<br/> Dim str As String<br/> If VarType(intPoints) <> vbEmpty Then<br/> For I = LBound(intPoints) To UBound(intPoints)<br/> str = "Intersection Point[" & k & "] is: " & intPoints(j) & "," & intPoints(j + 1) & "," & intPoints(j + 2)<br/> MsgBox str, , "IntersectWith Example"<br/> str = ""<br/> I = I + 2<br/> j = j + 3<br/> k = k + 1<br/> Next<br/> End If<br/>End Sub</p><p></p><p>这个例子中,通过判断数组是否为空,来看看是否有交点!</p> 有没有实体相交判断的例子
页:
[1]