I'm using SolidWorks 2011, x64, C#
The piece of code is as follows:
...
ModelDoc2 solidWorksDocument =SolidWorksApp.OpenDoc6(
@"C:\Test1.SLDASM",
(int)swDocumentTypes_e.swDocASSEMBLY,
0,
string.Empty,
ref errors,
ref warnings);
SolidWorksApp.ActivateDoc2("Test1.SLDASM", false, ref errors);
....
ModelDoc2 activeSolidWorksDocument = SolidWorksApp.ActiveDoc as ModelDoc2;
var status = activeSolidWorksDocument.Extension.SaveAs(@"C:\Example.XAML", 0, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref errors, ref warnings);
After execution, status = "false" and errors = 256.
BUT, when I test with part file, e.g. "C:\Test2.SLDPRT", and type using "(int) swDocumentTypes_e.swDocPART", the above piece of code works !
In addition, if I open solidworks 2011 and open "C:\Test1.SLDASM" and choose to save as xaml via menu commands, it succeed with assembly file and part file.
So I believe the exporting definitely can be done by API, maybe just missed some pre-setting before export, that could be the thing differ the menu command and the SaveAs function.
Does anybody has some idea to solve this problem ? Thanks a lot in advance !
SolidworksApi macros