Exported SLDPRT file in C# has 24KB, which is invalid.

Hello,

So I've started a few weeks ago to develop a C# code to call some Solidworks methods but have always faced this problem when exporting a SLDPRT file, which sometimes will return Error = 0, Warnings = 0, saved = true, but will result in a file with 24KB no matter the size of the input file.

The file Im importing is a Parasolid with 326MB, although this error is not specific to neither this file or with its size.

The code to import the Parasolid goes as follows:

int Err = 0;

ModelDoc2 swModel = null;

swModel = ( ModelDoc2 )job.SwInstance.LoadFile4( inputFilename, "r", null, ref Err );

At this point, swModel isnt Null anymore and Err=0. Everything is going well so far. Next step is to export to SLDPRT:

swModel = job.SwInstance.ActiveDoc as ModelDoc2;

swModel.ClearSelection2( true );

bool saved = swModel.Extension.SaveAs( outputFilename, ( int )swSaveAsVersion_e.swSaveAsCurrentVersion,

                ( int )swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref Err, ref Warnings );

I have the following option set for SLDPRT exporting (although there are some more, but for STL exporting):

swApp.SetUserPreferenceIntegerValue( ( int )swUserPreferenceIntegerValue_e.swSaveAssemblyAsPartOptions,

( int )swSaveAsmAsPartOptions_e.swSaveAsmAsPart_ExteriorFaces ); //Save SLDPRT as ExteriorFaces only

This is the point where Err = 0, Warnings = 0, saved = true and my resulting file size is 24KB. A workaround that works for me is to just retry the operation, which works 100% of the time. Unfortunately, this doesn't work on my client computer and even after retrying 5 times (which never happened to me, so I don't know how to debug it), it will still display no Error, warnings, and the file size will remain 24KB.

I'm starting solidworks with the following line, as suggested at :

SolidWorks = System.Diagnostics.Process.Start( SolidWorksPath( ), "/m" );

Before anyone asks, yes, this program I'm developing does open several Solidworks instances to run this conversion on each of them, but this error is happening regardless of if 1 or 6 instances are running.

Has anyone stumbled upon this? I'm using Solidworks 2018 SP2 on Windows 10 x64.

Let me know if I can be of any help or provide you with any more information. Thank you all!

SolidworksApi/macros