你这个方法我在AUTOCAD帮助中的开发文档里找到了,里面有个例子,是画线,画圆,然后求交点, 我复制过去,运行出现了错误,代码如下:
Public Sub CommandButton1_Click() UserForm1.Hide 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) UserForm1.Show End Sub
Public Sub CommandButton2_Click() UserForm1.Hide Dim circleObj As AcadCircle Dim centerPt(0 To 2) As Double Dim radius As Double centerPt(0) = 3: centerPt(1) = 3: centerPt(2) = 0 radius = 1 Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius) ZoomAll UserForm1.Show
End Sub
Public Sub CommandButton3_Click() UserForm1.Hide Dim intPoints As Variant Set intPoints = lineObj.IntersectWith(circleObj, 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 UserForm1.Show
End Sub 提示错误如下:运行错误‘424’
在Set intPoints = lineObj.IntersectWith(circleObj, acExtendNone)行上标示错误,
版主帮忙看一下,怎么回事 |