以下多段线顶点坐标输出的程序怎么不能用啊?
<p>Private Sub cd多段线坐标查询_Click()<br/> On Error Resume Next<br/> '安全创建选择集<br/> If Not IsNull(AcadApp.ActiveDocument.SelectionSets.Item("Test")) Then<br/> Set ssetObj = AcadApp.ActiveDocument.SelectionSets.Item("Test")<br/> ssetObj.Delete<br/> End If<br/> '创建选择集<br/> Set ssetObj = AcadApp.ActiveDocument.SelectionSets.add("Test")<br/> '激活CAD窗口<br/> AppActivate AcadApp.Caption<br/> AcadApp.WindowState = acMax<br/> '提示用户从屏幕选择实体对象,并加入选择集<br/> ssetObj.SelectOnScreen<br/> '选择完毕后按回车键或单击右键<br/> Dim pickedObjs As AcadEntity<br/> Dim retCoord As Variant<br/> For Each pickedObjs In ssetObj<br/> retCoord = pickedObjs.Coordinates<br/> AppActivate Me.Caption<br/> AcadApp.WindowState = acMin<br/> If TypeOf pickedObjs Is AcadPolyline Or TypeOf pickedObjs Is Acad3DPolyline Then '普通多义线或3维多段线<br/> j = (UBound(pickedObjs.Coordinates) + 1) / 3 '多义线的顶点数<br/> For i = 0 To j * 3 - 1 Step 3 If retCoord(0) = retCoord(j * 3 - 3) And retCoord(1) = retCoord(j * 3 - 2) Then '闭合时<br/> MSFlexGrid1.Rows = j<br/> Else '非闭合时<br/> MSFlexGrid1.Rows = j + 1<br/> End If<br/> MSFlexGrid1.TextMatrix(i / 3 + 1, 0) = i / 3 + 1<br/> MSFlexGrid1.TextMatrix(i / 3 + 1, 2) = Format(retCoord(i) / 1000 * Val(Text比例.Text), "0.000")<br/> MSFlexGrid1.TextMatrix(i / 3 + 1, 1) = Format(retCoord(i + 1) / 1000 * Val(Text比例.Text), "0.000") </p><p> Next i<br/> ElseIf TypeOf pickedObjs Is AcadLWPolyline Then '轻便多义线<br/> j = (UBound(pickedObjs.Coordinates) + 1) / 2 '多义线的顶点数<br/> For i = 0 To j * 2 - 1 Step 2 If retCoord(0) = retCoord(j * 2 - 2) And retCoord(1) = retCoord(j * 2 - 1) Then '闭合时<br/> MSFlexGrid1.Rows = j<br/> Else '非闭合时<br/> MSFlexGrid1.Rows = j + 1<br/> End If<br/> MSFlexGrid1.TextMatrix(i / 2 + 1, 0) = i / 2 + 1<br/> MSFlexGrid1.TextMatrix(i / 2 + 1, 2) = Format(retCoord(i) / 1000 * Val(Text比例.Text), "0.000")<br/> MSFlexGrid1.TextMatrix(i / 2 + 1, 1) = Format(retCoord(i + 1) / 1000 * Val(Text比例.Text), "0.000")</p><p> Next i<br/> Else<br/> MsgBox "您选择的不是多段线!", 64 + vbOKOnly, "地质测量"<br/> ssetObj.Delete<br/> End If<br/> Exit For<br/> Next<br/> '删除选择集<br/> ssetObj.Delete<br/>End Sub</p>
页:
[1]