- UID
- 219245
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-2-23
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在.DXF文件里提取离散点,并将其保存为surfer可以直接读取的文件格式,在surfer中生成曲面。
程序如下(VB)其中要添加一些基本的控建如:ComDlg,Command1:
Private Sub Command1_Click()
Dim a, b, c As String
Dim xx, yy, zz As String
Dim X(), Y(), Z() As String
'Dim FJ As String
Dim Line, I, J As Integer, pp As Integer
Dim wzp() As String
Line = 0
J = 0
On Error Resume Next
With ComDlg'读取文件
.DialogTitle = "选择文本文件"
.Filter = "DXF文件(*.dxf)|*.dxf|文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
.InitDir = "D:\"
.ShowOpen
End With
If Right(ComDlg.FileName, 3) <> "dxf" And Right(ComDlg.FileName, 3) <> "txt" Then
MsgBox "不支持的文件格式!", vbCritical, "警告"
Exit Sub
End If
Open ComDlg.FileName For Input As #1
Do While Not EOF(1)
Line = Line + 1
Input #1, a
If a = "AcDbPoint" Then
Input #1, b
Input #1, xx
Input #1, b
Input #1, yy
Input #1, b
Input #1, zz
'ReDim X(0 To 17), Y(0 To 17), Z(0 To 17) As String
Dim FJ(1 To 17) As String
J = J + 1
FJ(J) = xx & "," & yy & "," & zz
'MsgBox "X=" & X(J) & " Y=" & Y(J) & " Z=" & Z(J), vbInformation, "提示"
End If
Loop
'MsgBox FJ(J), vbInformation, "提示"
Text1.Text = Line
Text2.Text = J
If J = 0 Then
MsgBox "没有点数据!", vbOKOnly, "提示"
Exit Sub
End If
Close #1
'***************************需要重新赋值**************************
Dim wzp1(1 To 17) As String
For J = 1 To 17
wzp1(J) = FJ(J)
Next J
'MsgBox "X=" & X(J) & " Y=" & Y(J) & " Z=" & Z(J), vbInformation, "提示"
Dim JGname As String
JGname = ComDlg.FileName
JGname = Left(JGname, Len(JGname) - 4) & "结果.txt"'生成新的名称
Open JGname For Output As #1
Print #1, "X,", "Y,", "Z"
'Print #1, FJ
For J = 1 To 17
Print #1, wzp1(J) ', Y(I), Z(I)
Next J
Close #1
MsgBox "转换完毕!", vbOKOnly, "提示"
End Sub
可以用下面的TXT文件试试:) |
|