SUModelSaveToFile doesn't create file on Release build with msvc

So on msvc2022 when I compile the x64 Release build with latest SDK - so on Debug x64 it’s slower but at the end it creates a file in the project directory, but with the release one I don’t see the output model.

I use:

SUModelSaveToFile(model, “new_model.skp”),

To terminate. Thanks in advance.

Forget the memory part - it’s unrelated - but I consistently get the above problem.


Just a quick guess: maybe when you debug you are running the app as administrator. Try running the release app as administrator. It can be a directory or file access rights issue.


I agree. All the file operations for all SketchUp APIs will operate on the current working directory unless you use a full absolute path.

If not using absolute paths, save the working directory before using a file function, set it to your target path and reset if after.

Take note of the Memory Management in the SketchUp C API section of the API main page:

1 Like

Yeah I save it under my project folder - I run both Debug And Release from Visual Studio and they both operate on the same directory - don’t know how one could have different permission.

Oh you are saying the Release build may have different current directory - but also I had the same issue running outside Visual Studio and the Release build doesn’t save in the current directory.

It’s a simple cmd app - I don’t change my working directory.

This has nothing to do with VS. It is all about where the model file is saved at runtime of your app.

But what is it? Any other app could change the WD at any time.
It is always safer to use absolute file paths.

Ie … your sample code was only a .skp file name without a path.

Ok I understand - will try an absolute directory next time - hopefully it works this way thanks.