Writing text from a dwg to a text file?
Writing text from a dwg to a text file?
(OP)
Hello again guys. I am having trouble writing text from my dwg to a text file.
I have no problem counting the number of text items and I can easily put text into a dwg but when I try to read the text and write it to a file I'm having a very hard time.
I would like to know how to read a DrawingText into a variable. Any examples????
Thanks,
John
I have no problem counting the number of text items and I can easily put text into a dwg but when I try to read the text and write it to a file I'm having a very hard time.
I would like to know how to read a DrawingText into a variable. Any examples????
Thanks,
John





RE: Writing text from a dwg to a text file?
<script language="VBScript" type="text/VBScript">
Set CATIA = GetObject(, "CATIA.Application")
Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets
Set Selection = DrwDocument.Selection
Set DrwSheet = DrwSheets.ActiveSheet
Set DrwView = DrwSheet.Views.ActiveView
Set DrwTexts = DrwView.Texts
Dim oText
file_set = "C:\inetpub\wwwroot\eng1\dwg_notes\backup\dwg_notes2.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.CreateTextFile(file_set, True)
Set AllTexts = DrwView.Texts
if AllTexts.Count > 0 Then
For Each oText In AllTexts
ts.WriteLine oText.Text
Next
End If
ts.close
</script>
I keep getting the Error "object does not support this action 'Text'.
I can understand why I keep getting this. Which is saying that the oText.Text line is not valid???????
Thanks for your help.
RE: Writing text from a dwg to a text file?
this should do the job:
...
for i=1 to AllTexts.count
ts.WriteLine AllTexts.Item(i).Text
next
Regards TPale