- 积分
- 755
- 明经币
- 个
- 注册时间
- 2004-2-27
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-4-7 08:42:00
|
显示全部楼层
可以
Sub Example_IntersectWith() ' This example creates a line and circle and finds the points at ' which they intersect. ' Create the line Dim lineObj As AcadLine Dim startPt(0 To 2) As Double Dim endPt(0 To 2) As Double startPt(0) = 1: startPt(1) = 1: startPt(2) = 0 endPt(0) = 5: endPt(1) = 5: endPt(2) = 0 Set lineObj = ThisDrawing.ModelSpace.AddLine(startPt, endPt) 'Create the face Dim Plate As Acad3DFace Dim Pt1(0 To 2) As Double Dim Pt2(0 To 2) As Double Dim Pt3(0 To 2) As Double Dim Pt4(0 To 2) As Double Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0 Pt2(0) = 1: Pt2(1) = 0: Pt2(2) = 0 Pt3(0) = 1: Pt3(1) = 1: Pt3(2) = 0 Pt4(0) = 0: Pt4(1) = 1: Pt4(2) = 0 Set Plate = ThisDrawing.ModelSpace.Add3DFace(Pt1, Pt2, Pt3, Pt4) ZoomAll ' Find the intersection points between the line and the face Dim intPoints As Variant intPoints = lineObj.IntersectWith(Plate, acExtendNone)
' Print all the intersection points Dim I As Integer, j As Integer, k As Integer Dim str As String If VarType(intPoints) <> vbEmpty Then For I = LBound(intPoints) To UBound(intPoints) str = "Intersection Point[" & k & "] is: " & intPoints(j) & "," & intPoints(j + 1) & "," & intPoints(j + 2) MsgBox str, , "IntersectWith Example" str = "" I = I + 2 j = j + 3 k = k + 1 Next End If End Sub
我只举了一个最简单的例子。要提醒你的是线与面可能有无数个交点! |
|