关于VBA的输出问题
请问用VBA能不能实现将图的一些数据写入一个文件。如TEXT!然后还可以把该数据读入图中。想LISP一样! 自己顶! Option Explicit'将数据写入文件Public Sub WriteToFile()Dim TextObj As AcadText
Set TextObj = ThisDrawing.ModelSpace(0)
Open "C:\ACADText.txt" For Output As #1
Write #1, TextObj.TextString
Close #1
End Sub'从文件读出数据Public Sub ReadFromFile()
Dim TextObj As AcadText
Set TextObj = ThisDrawing.ModelSpace(0)
Dim s As String
Open "C:\ACADText.txt" For Input As #1
Input #1, s
TextObj.TextString = s
Close #1
End Sub 谢谢尹凡<BR> 我可以先不去啃ADL了 我在CAD里面画了一条线。然后运行了下。提示类型不匹配! 类型不对是因为我是用文字对象来测试,你先新建一张图纸,然后创建一个单行文字的实体,就可以运行了。 哦。谢谢哈! 请尹凡在指点我下。我现在卡壳了。一下午没什么 进展!
就是如果想把任意一个点的坐标输出到一个文件里面! Option Explicit
Sub WriteToFile()<BR> Dim sset As AcadSelectionSet<BR> Dim i As Integer<BR> Dim txtout As String<BR> Dim coord As Variant<BR> For i = 0 To ThisDrawing.SelectionSets.Count - 1<BR> ThisDrawing.SelectionSets.Item(i).Clear<BR> ThisDrawing.SelectionSets.Item(i).Delete<BR> Next<BR> Set sset = ThisDrawing.SelectionSets.Add("tt")<BR> sset.SelectOnScreen<BR> <BR> For i = 0 To sset.Count - 1<BR> coord = sset.Item(i).Coordinates<BR> txtout = txtout & coord(0) & "," & coord(1) & "," & coord(2) & vbCrLf<BR> Next
Open "l:\ACADText.txt" For Output As #1<BR> Print #1, txtout<BR> Close #1<BR>End Sub<BR> 谢谢斑竹,因为忙别的事,好久没来了。但是好象没有输出啊。文本里面是空白啊!
页:
[1]
2