大侠们好!我现在已有一张CAD图,想通过VBA实现获取里面的所有样条曲线的拟合点的坐标,我的代码如下: Sub Select_GetFitPoint() ' This example selects a spline object in model space. ' It then finds the coordinates of the fit points. ' select the spline ' 创建新的选择集 Dim ssetObj As AcadSelectionSet 'Dim splineObj As AcadSpline Set ssetObj = ThisDrawing.SelectionSets.Add("SSpline") '构建过滤器 Dim fType As Variant, fData As Variant Call CreateSSetFilter(fType, fData, 0, "Spline")
' 提示用户选择样条曲线对象并将它们添加到选择集中。
' 要完成选择,按回车。 ssetObj.SelectOnScreen fType, fData ZoomAll ' Display the coordinates of the fit points Dim fitPoint As Variant Dim index As Integer For index = 0 To ssetObj.NumberOfFitPoints - 1 fitPoint = ssetObj.GetFitPoint(index) MsgBox "Fit point " & index + 1 & " is at " & fitPoint(0) & ", " & fitPoint(1) & ", " & fitPoint(2), , "GetFitPoint Example" Next End Sub ' 创建选择集过滤器 Public Sub CreateSSetFilter(ByRef filterType As Variant, ByRef filterData As Variant, ParamArray filter()) If UBound(filter) Mod 2 = 0 Then MsgBox "filter参数无效!" Exit Sub End If Dim fType() As Integer ' 过滤器规则 Dim fData() As Variant ' 过滤器参数 Dim count As Integer count = (UBound(filter) + 1) / 2 ReDim fType(count - 1) ReDim fData(count - 1) Dim i As Integer For i = 0 To count - 1 fType(i) = filter(2 * i) fData(i) = filter(2 * i + 1) Next i filterType = fType filterData = fData End Sub 调试发现ssetObj对象不能调用GetFitPoint()这个方法,请问应该怎么改代码呢?谢谢! |