VB版本,怎么这么乱?- <CommandMethod("addRibbon")> _Public Sub addRibbon() 'MessageBox.Show(""); Dim files As New List(Of String)() Dim openDialog As New System.Windows.Forms.OpenFileDialog() openDialog.Multiselect = True openDialog.Filter = "数据文件|*.dat" openDialog.Title = "选择数据文件(可多选)" openDialog.RestoreDirectory = False If openDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then For Each file As String In openDialog.FileNames files.Add(file) Next End If For Each file As String In files PointOutNet(file) NextEnd SubPublic Sub PointOutNet(FileName As String) Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Dim strArray As String() Dim data As New List(Of String)() Dim dataNew As New List(Of String())() Dim fStream As New FileStream(FileName, FileMode.Open) Dim sReader As New StreamReader(fStream) Dim dataRow As String = sReader.ReadLine() While dataRow IsNot Nothing data.Add(dataRow) dataRow = sReader.ReadLine() End While sReader.Close() For Each pt As String In data strArray = pt.Split(New Char() {","C}) If strArray.Length >= 5 Then dataNew.Add(strArray) End If Next Using trans As Transaction = db.TransactionManager.StartTransaction() Dim bt As BlockTable = DirectCast(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable) Dim btr As BlockTableRecord = DirectCast(trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord) For Each pt As String() In dataNew Dim y As Double = Convert.ToDouble(pt(2)) Dim x As Double = Convert.ToDouble(pt(3)) Dim h As Double = Convert.ToDouble(pt(4)) Dim p1 As New Point3d(y, x, h) Dim newPoint As New DBPoint(p1) btr.AppendEntity(newPoint) trans.AddNewlyCreatedDBObject(newPoint, True) Next trans.Commit() End UsingEnd Sub
|