overwrite .stp file with a macro

Marco Signorini

overwrite .stp file with a macro

Hello everyone, I'm new in the forum so if this is not the correct place to ask I'll remove the topic and open it in the appropriate section.
I'm looking for some advices related to a macro I'm writing to work on CATIA V5 R20.

Briefly, this macro has to open a file, update it with some data coming from a design table linked with excel and then export the part as an .stp file. I need to make this macro completely automatized but, when CATIA exports the .stp file it asks if I want to overwrite the existing file or not. I can't delete the file manually, so my question is: is there a way to give CATIA the option to overwrite the file without a manual intervention?

this is the code I recorded using the "macro recording" option:



Sub CATMain()

Set documents1 = CATIA.Documents

Set partDocument1 = documents1.Open("D:\Desktop\Borsa\ModeFrontier\car_shell_base.CATPart")

Set part1 = partDocument1.Part


Set partDocument1 = CATIA.ActiveDocument

partDocument1.ExportData "D:\Desktop\Borsa\ModeFrontier\car_shell.stp", "stp"

Set partDocument1 = CATIA.ActiveDocument


End Sub


thanks in advice

Phil Harrison

RE: overwrite .stp file with a macro
(in response to Marco Signorini)

I was waiting to see if anyone had a clever way of answering this issue as I had a similar problem 15 years or so ago when developing my performance benchmark scripts.

What I ended up doing is to have a directory to write output files to. I call my macro from a batch file after I have erased everything in that directory so I am assured I can write to the directory. If you wanted after running the macro the batch file could then overwrite the original stl/stp file. So in order the batch file:

1. Deletes everything in an output directory

2. Calls CATIA to start & run my macro which exports the stp file

3. overwrites the original stp file

Phil Harrison

COE V6 Certified Professional

COE President 1996-2005

Edited By:
Phil Harrison[Organization Members] @ Mar 02, 2020 - 10:19 AM (America/Eastern)