edi-000 发表于 2007-10-16 21:26:00

[求助]请教此代码为何不能得到样条曲线拟合点的UCS坐标值,而只能得到其WCS坐标值?

[求助]请教此代码为何不能得到样条曲线拟合点的UCS坐标值,而只能得到其WCS坐标值?谢谢<p>Sub test_AddOrgUCS()<br/>&nbsp;&nbsp;&nbsp; '原点UCS调用示例<br/>&nbsp;&nbsp;&nbsp; Dim myUCS As AcadUCS, NewOrgPt As Variant<br/>&nbsp;&nbsp;&nbsp; NewOrgPt = ThisDrawing.Utility.GetPoint(, vbCrLf &amp; "请输入新原点:")<br/>&nbsp;&nbsp;&nbsp; Set myUCS = AddOrgUCS(NewOrgPt, "abc")<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveUCS = myUCS<br/>&nbsp;&nbsp;&nbsp;&nbsp; ' This example selects a spline object in model space.<br/>&nbsp;&nbsp;&nbsp; ' It then finds the coordinates of the fit points.</p><p>&nbsp;&nbsp;&nbsp; Dim ssetObj As AcadSelectionSet</p><p>&nbsp;&nbsp;&nbsp; Set ssetObj = ThisDrawing.SelectionSets.Add("SSpline")</p><p>&nbsp;&nbsp;&nbsp; Dim fType As Variant, fData As Variant<br/>&nbsp;&nbsp;&nbsp; Call CreateSSetFilter(fType, fData, 0, "Spline")</p><p><br/>&nbsp;&nbsp;&nbsp; ' 提示用户选择样条曲线对象并将它们添加到选择集中。</p><p>&nbsp;&nbsp;&nbsp; ' 要完成选择,按回车。<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ssetObj.SelectOnScreen fType, fData</p><p>&nbsp;&nbsp;&nbsp; ZoomAll<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Display the coordinates of the fit points<br/>&nbsp;&nbsp;&nbsp; Dim fitPoint As Variant<br/>&nbsp;&nbsp;&nbsp; Dim index As Integer<br/>&nbsp;&nbsp;&nbsp; For i = 0 To ssetObj.count - 1<br/>&nbsp;&nbsp;&nbsp; For index = 0 To ssetObj(i).NumberOfFitPoints - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fitPoint = ssetObj(i).GetFitPoint(index)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "拟合点" &amp; index + 1 &amp; " 的坐标为: " &amp; fitPoint(0) &amp; ", " &amp; fitPoint(1) &amp; ", " &amp; fitPoint(2), , "GetFitPoint Example"<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; <br/>End Sub</p><p>Public Sub CreateSSetFilter(ByRef filterType As Variant, ByRef filterData As Variant, ParamArray filter())<br/>&nbsp;&nbsp;&nbsp; If UBound(filter) Mod 2 = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "filter参数无效!"<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim fType() As Integer<br/>&nbsp;&nbsp;&nbsp; Dim fData() As Variant<br/>&nbsp;&nbsp;&nbsp; Dim count As Integer<br/>&nbsp;&nbsp;&nbsp; count = (UBound(filter) + 1) / 2<br/>&nbsp;&nbsp;&nbsp; ReDim fType(count - 1)<br/>&nbsp;&nbsp;&nbsp; ReDim fData(count - 1)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim i As Integer<br/>&nbsp;&nbsp;&nbsp; For i = 0 To count - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fType(i) = filter(2 * i)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fData(i) = filter(2 * i + 1)<br/>&nbsp;&nbsp;&nbsp; Next i<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; filterType = fType<br/>&nbsp;&nbsp;&nbsp; filterData = fData<br/>End Sub</p><p>' 移动原点创建UCS<br/>' ptOriginWcs:新UCS的原点在WCS中的坐标<br/>Public Function AddOrgUCS(ptOriginWcs As Variant, strUcsName As String) As AcadUCS<br/>&nbsp;&nbsp;&nbsp; ' 获得新UCS原点在当前UCS中的坐标<br/>&nbsp;&nbsp;&nbsp; Dim ptOriginUcs As Variant<br/>&nbsp;&nbsp;&nbsp; ptOriginUcs = PtWcs2Ucs(ptOriginWcs)<br/>&nbsp;&nbsp;&nbsp; 'Debug.Print ptOriginWcs(0)<br/>&nbsp;&nbsp;&nbsp; ' 获得X、Y正半轴上任一点的UCS坐标<br/>&nbsp;&nbsp;&nbsp; Dim ptXUcs(0 To 2) As Double, ptYUcs(0 To 2) As Double<br/>&nbsp;&nbsp;&nbsp; ptXUcs(0) = ptOriginUcs(0) + 1<br/>&nbsp;&nbsp;&nbsp; ptXUcs(1) = ptOriginUcs(1)<br/>&nbsp;&nbsp;&nbsp; ptXUcs(2) = ptOriginUcs(2)<br/>&nbsp;&nbsp;&nbsp; ptYUcs(0) = ptOriginUcs(0)<br/>&nbsp;&nbsp;&nbsp; ptYUcs(1) = ptOriginUcs(1) + 1<br/>&nbsp;&nbsp;&nbsp; ptYUcs(2) = ptOriginUcs(2)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 获得X、Y正半轴上任一点的WCS坐标<br/>&nbsp;&nbsp;&nbsp; Dim ptXWcs As Variant, ptYWcs As Variant<br/>&nbsp;&nbsp;&nbsp; ptOriginWcs = PtUcs2Wcs(ptOriginUcs)<br/>&nbsp;&nbsp;&nbsp; ptXWcs = PtUcs2Wcs(ptXUcs)<br/>&nbsp;&nbsp;&nbsp; ptYWcs = PtUcs2Wcs(ptYUcs)<br/>&nbsp;&nbsp;&nbsp; 'Debug.Print ptOriginWcs(0)<br/>&nbsp;&nbsp;&nbsp; ' 创建UCS<br/>&nbsp;&nbsp;&nbsp; Set AddOrgUCS = ThisDrawing.UserCoordinateSystems.Add(ptOriginWcs, ptXWcs, ptYWcs, strUcsName)<br/>End Function</p><p>' 将点的UCS坐标转化到WCS坐标<br/>Private Function PtUcs2Wcs(ptUcs As Variant) As Variant<br/>&nbsp;&nbsp;&nbsp; PtUcs2Wcs = ThisDrawing.Utility.TranslateCoordinates(ptUcs, acUCS, acWorld, False)<br/>End Function</p><p>' 将点的WCS坐标转化到UCS坐标<br/>Private Function PtWcs2Ucs(ptWcs As Variant) As Variant<br/>&nbsp;&nbsp;&nbsp; PtWcs2Ucs = ThisDrawing.Utility.TranslateCoordinates(ptWcs, acWorld, acUCS, False)<br/>End Function<br/></p>
页: [1]
查看完整版本: [求助]请教此代码为何不能得到样条曲线拟合点的UCS坐标值,而只能得到其WCS坐标值?