Preview | SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
WWWilliam Wedler15/12/2011
Hi, I am attempting to edit part metadata and then save using the Document Manager. I can connect to the document manager, open the document and manipulate metadata. However, I am not able to save the file. I get an error return.
The return value is swDmDocumentSaveErrorFail which corrseponds to "2 = Failed; reason could be related to permissions" according to the API help.
I am running solidworks 2010 x64 SP4.0 and my machine is running Windows 7 x64. The file is located on my hard drive, as is the code I am executing. Has anybody seen similar issues? Any suggestions?
Here is what my code looks like:
public void TestSaveDMDoc() { String strPath = testroot+@"\TestFileOps\Part.SLDPRT"; SwDMClassFactory swClassFact = new SwDMClassFactory(); SwDMApplication swDocMgr = swClassFact.GetApplication(UtilController.strLicenseKey); SwDmDocumentType dmType = SwDmDocumentType.swDmDocumentPart; SwDmDocumentOpenError errOpen; SwDmDocumentSaveError errSave; SwDMDocument14 doc = (SwDMDocument14)swDocMgr.GetDocument(strPath, dmType, true, out errOpen); if (errOpen != SwDmDocumentOpenError.swDmDocumentOpenErrorNone) { throw new Exception("Could not open the file"); } Assert.IsNotNull(doc); errSave = doc.Save(); if (errSave != SwDmDocumentSaveError.swDmDocumentSaveErrorNone) { String strMessage = "Failed to save."; if ((errSave & SwDmDocumentSaveError.swDmDocumentSaveErrorFail) == SwDmDocumentSaveError.swDmDocumentSaveErrorFail) { strMessage += "Fail error. Problem could be related to permissions."; } if ((errSave & SwDmDocumentSaveError.swDmDocumentSaveErrorReadOnly) == SwDmDocumentSaveError.swDmDocumentSaveErrorReadOnly) { strMessage += "Read only error. File was opened as read-only."; } throw new Exception(strMessage); } Assert.AreEqual(SwDmDocumentSaveError.swDmDocumentSaveErrorNone, doc.Save()); }
When I run the code, it throws an exception indicating a fail error occured when attempting to save.
Thanks, Will