There are multiple methods for exporting information to .TXT notepad files while running your CATIA macro. The first example is from my Export Spec Tree code found in the CATIA Macro Pack.  The data is exported directly to .TXT but we’re not modifying anything other than the file name.

The second option to export to TXT is a bit more dynamic as it allows you to write information to the .txt file at any point during your program. The following code illustrates how we can use the FileSystemObject to return a TextStream object that can be read from or written to:

In my code shown above, the CreateObject function returns the FileSystemObject (fs). The CreateTextFile method then creates the TXT file and the WriteLine method allows us to write anything we want in the newly created TXT file. The Close method closes the file when we’re finished writing. vbTab is used to indent while vbLf is used to go to the next line. See a complete list of VB constants here.

Instead of using the BOM tool you can use this txt exportation method to create custom Bills of Material with a CATIA macro. It’s another good tool for troubleshooting and making sure variables at different points in your code are what you expect them to be.

Do you export data to TXT and if so how often?