XCAFApp_Application SaveAs failed

Hi, I'm trying to save a document with some data in it and it fails.

Handle(XCAFApp_Application) anApp = wxGetApp().GetOCCApp();
Handle(TDocStd_Document) aDoc;
anApp->GetDocument(1,aDoc);
TCollection_ExtendedString theStatusMessage;
aDoc->ChangeStorageFormat(TCollection_ExtendedString("XmlXCAF"));
PCDM_StoreStatus status = anApp->SaveAs(aDoc,"C:\Documents\file.XmlXCAF",theStatusMessage);

Error message is:
driver failed; reason:Could not found the resource definition:XmlXCAF.StoragePlugin

mfregeau's picture

I got it, I had to load the drivers for it:

BinXCAFDrivers::DefineFormat (occApp);
XmlXCAFDrivers::DefineFormat (occApp);