I don't believe I can help you with your problem, but I sure would love to know how you managed to create the DXF output task.
I have never had luck with the replace existing files option. I don't know if it has to do with the original file not being checked out or what.
DXF creation: The easiest way I found to do it was to have a second sheet named "Flat Pattern". Then run the DXF task for only sheets with that name. I found it was the best way so that counter sinks were on the correct side for punching.
I managed to somehow solve the problem. It turned out that "Replace existing files" or "Create new version of existing files" don't work if task is run by SW 2017 or older ("SOLIDWORKS version to use" option under "Advanced Scripting Options..." under Task properties), but it works fine if run by SW 2018. The output DXF file is neither automatically checked in after conversion if task run by SW 2017 or older, but it gets automatically checked in if run by SW 2018.
I do not know the reason behind this behaviour, but obviously some additional funcitionality was added to SW 2018 API.
I look forward for any additional insight how to achieve automatic Check in of DXF file if Task run in SW 2017 or older, since some of our customers still prefer to use older SW version.
By the way, I did DXF conversion of Flat pattern sheet metal directly on part (not on Flat pattern drawing) by modifying Default PDM Convert Task script using ExportToDWG API method.
I also can't answer your question, but I've tried just about everything I can come up with to make ExportToDWG work from a Task, to no avail...every time, the function returns False and doesn't save, although no errors are thrown.
Did you ever see this behavior? Any suggestions for what might be preventing it from running properly as a Task, even though the macro by itself works properly?
The same situation with conversion of files of SolidWorks to TIF and other formats is familiar to me.
Therefore, I do not think that it is connected to a filename extension.
In SolidWorks PDM 2018 "Create new version of existing files" works provided that the file which should be replaced before this is CheckOut. It is better to make it automatically, for example through Dispatch.
But I noted even earlier that if the replaced file is selected in the PDM window - the file will not be replaced.
There are no warnings - just the system reads that the file - Locked.
I checked - if to remove a choice (cursor) from the file the PDM window - everything works without problems.
Also the file can be Locked some other application or Add-Ins.
It can be checked, for example by means of the program - "Unlocker".
As I think - a problem that the replaced file is occupied with some process.
And for its changeover - it shall be before this Unlocked (programmatically or in a different way).
Perhaps, it has no relation to this situation, then if in the task the code is used - to check the used SolidWorks version - there is it matters.
Also, a problem in the Workflow settings for example it can be possible to try to ignore permissions in the previous statuses.