- 积分
- 8605
- 明经币
- 个
- 注册时间
- 2004-6-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click '提取坐标
SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle) 'CAD获得焦点
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim enOpts As PromptEntityOptions = New PromptEntityOptions("选择一条多段线")
Dim enRes As PromptEntityResult = ed.GetEntity(enOpts)
If enRes.Status = PromptStatus.OK Then
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim en As Entity = CType(trans.GetObject(enRes.ObjectId, OpenMode.ForRead), Entity)
If TypeOf en Is Polyline Then
Dim pl As Polyline = CType(en, Polyline)
Dim pts_len As Integer = pl.NumberOfVertices
Dim i As Integer
For i = 0 To pts_len - 1
Dim JS As Integer = 0
JS = i + 1
ListBox1.Items.Add("X" & JS & "=" & pl.GetPoint3dAt(i).X.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("Y" & JS & "=" & pl.GetPoint3dAt(i).Y.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("H" & JS & "=" & pl.GetPoint3dAt(i).Z.ToString("0.000") & vbCrLf)
'ed.WriteMessage(pl.GetPoint3dAt(i).ToString() + "\n")
Next
ElseIf TypeOf en Is Polyline3d Then
'三维多段线
???
ElseIf TypeOf en Is Line Then
Dim pl As Line = CType(en, Line)
ListBox1.Items.Add("XA=" & pl.StartPoint.X.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("YA=" & pl.StartPoint.Y.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("HA=" & pl.StartPoint.Z.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("XB=" & pl.EndPoint.X.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("YB=" & pl.EndPoint.Y.ToString("0.000") & vbCrLf)
ListBox1.Items.Add("HB=" & pl.EndPoint.Z.ToString("0.000") & vbCrLf)
Else
ed.WriteMessage("你选择的是" + en.GetRXClass().Name)
End If
trans.Commit()
End Using
End If
|
|