Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

CorruptModelException during Autodesk.Revit.DB.Document.SaveAs

andreas.baumannQN98X
Explorer

CorruptModelException during Autodesk.Revit.DB.Document.SaveAs

andreas.baumannQN98X
Explorer
Explorer
Hi,
we have a piece if code, that's running fine on every machine that we tested it on, but on some user's PC it will always throw a CorruptModelException with this message: "The model could not be saved: Unbekannter Fehler beim Zugriff auf eine unbenannte Datei. (CArchiveException 1)"
 
(translation of the german part: unknown error while accessing an unnamed file)

This error seems to be impossible to reproduce on my system.

Heres the failing code. I believe, the Exception is thrown in the last line.

 

...

Document doc = null;

if (docTemplatePath.EndsWith(".rte"))
    doc = app.Application.NewProjectDocument(docTemplatePath);
else
    doc = app.Application.OpenDocumentFile(docTemplatePath);

SaveAsOptions saveAsOptions = new SaveAsOptions();
saveAsOptions.OverwriteExistingFile = true;

if (activateWorksharing != null && activateWorksharing == "true")
{
    doc.EnableWorksharing(WWBRevitApp.resourceManager.GetString("WWBRevitEventHandler_WorksetName"), WWBRevitApp.resourceManager.GetString("WWBRevitEventHandler_WorksetNameGridLevel"));
    WorksharingSaveAsOptions worksharingSaveAsOptions = new WorksharingSaveAsOptions();
    worksharingSaveAsOptions.SaveAsCentral = true;
    worksharingSaveAsOptions.OpenWorksetsDefault = SimpleWorksetConfiguration.AllWorksets;
    saveAsOptions.SetWorksharingOptions(worksharingSaveAsOptions);
}

doc.SaveAs(docCreateNewPath, saveAsOptions);

 

I assumed, that maybe the user passes a path, he doesn't have write access on, but the exception seems to be thrown no matter what path he uses. The .rte file he uses seems to be ok as well. As I said, the code would run fine on my machine using the same template file. If he creates a new project with that template file manually, everything is fine as well.
 
I'm kinda out of ideas, what the problem might be. Anybody seen this error before?
 
Thanks,
Andreas
0 Likes
Reply
Accepted solutions (1)
292 Views
3 Replies
Replies (3)

caroline.gitonga
Autodesk
Autodesk

Hi @andreas.baumannQN98X ,

There is a umber of reasons you could get this error using Autodesk.Revit.DB.Document.SaveAs:
Temporary lost of the connection (network failure) with a location the file was opened from:
In case you opened the file from a network location you have to make sure you have this location accessible all the time you are working with this file. If this cannot be secured, copy the file on your local drive first and then open it.

Lack of free disk space:
Maybe your destination disk do not have enough space to save the file.

Folder permissions:
Having no rights to write to the disk.

I am not very sure what the exact issue causing this error.

Please do provide the model and a reproducible case, including the journal file, so that we can reproduce it in house

 

Carol Gitonga, Developer Advocacy and Support, ADN Open
0 Likes

andreas.baumannQN98X
Explorer
Explorer

Hi @caroline.gitonga,

 

so I got the users journal files and the problem turned out to be an almost but not too long target path. The target path for the new File was a little bit shorter than the limit of 260 characters, so it seemed to be fine, but the additional files that are written to the "_backup" folder exceeded that limit. That's what caused the CorruptModelException. 

 

I guess this issue can be closed, but is there a way to use paths larger than 260 characters.

 

Thanks,

Andreas

caroline.gitonga
Autodesk
Autodesk
Accepted solution

Hi @andreas.baumannQN98X,

Glad you were able to figure this is out.  

About the path length limitation, its not really a Revit issue but more of the Windows. Kindly, refer to this resource on how to extend the path length limit.

Maximum Path Length Limitation - Win32 apps | Microsoft Docs

 

If you find this helpful, kindly mark it as solved.

Carol Gitonga, Developer Advocacy and Support, ADN Open
0 Likes