public void PublishCmd_Callback() { try { string tmp_file_path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); File.Delete(tmp_file_path); tmp_file_path = Path.ChangeExtension(tmp_file_path, ".stl"); int modelType = SwApp.IActiveDoc2.GetType(); bool curOptionValue = false; if (modelType == (int)swDocumentTypes_e.swDocASSEMBLY) { curOptionValue = SwApp.GetUserPreferenceToggle ( (int)swUserPreferenceToggle_e.swSTLComponentsIntoOneFile ); if (curOptionValue == false) { SwApp.SetUserPreferenceToggle ( (int)swUserPreferenceToggle_e.swSTLComponentsIntoOneFile, true ); } } int errors = 0; int warnings = 0; bool isOK = SwApp.IActiveDoc2.Extension.SaveAs( tmp_file_path, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent | (int)swSaveAsOptions_e.swSaveAsOptions_OverrideSaveEmodel, null, ref errors, ref warnings); string thumbnail = "";// saveImage(); //*************************************** // magic happens here SketchfabPublisher.ParametersForm form = new SketchfabPublisher.ParametersForm( modelPath: tmp_file_path, modelName: this.ModelName, description: this.Description, tags: this.Tags, token: null, imagePath: thumbnail, source: "solidworks-" + getSWVersion() ); if (form.ShowDialog() == DialogResult.OK && form.ToSaveSummaryInfo) { this.ModelName = form.ModelTitle; this.Description = form.ModelDescription; this.Tags = form.ModelTags; } //*************************************** if (modelType == (int)swDocumentTypes_e.swDocASSEMBLY) { SwApp.SetUserPreferenceToggle ( (int)swUserPreferenceToggle_e.swSTLComponentsIntoOneFile, curOptionValue ); } //File.Delete(thumbnail); File.Delete(tmp_file_path); } catch { } }
public void PublishCmd_Callback() { try { string tmp_file_path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); File.Delete(tmp_file_path); tmp_file_path = Path.ChangeExtension(tmp_file_path, ".stl"); int modelType = SwApp.IActiveDoc2.GetType(); bool curOptionValue = false; if (modelType == (int)swDocumentTypes_e.swDocASSEMBLY) { curOptionValue = SwApp.GetUserPreferenceToggle ( (int)swUserPreferenceToggle_e.swSTLComponentsIntoOneFile ); if (curOptionValue == false) { SwApp.SetUserPreferenceToggle ( (int)swUserPreferenceToggle_e.swSTLComponentsIntoOneFile, true ); } } int errors = 0; int warnings = 0; bool isOK = SwApp.IActiveDoc2.Extension.SaveAs( tmp_file_path, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent | (int)swSaveAsOptions_e.swSaveAsOptions_OverrideSaveEmodel, null, ref errors, ref warnings); string thumbnail = "";// saveImage(); //*************************************** // magic happens here SketchfabPublisher.ParametersForm form = new SketchfabPublisher.ParametersForm( modelPath: tmp_file_path, modelName: this.ModelName, description: this.Description, tags: this.Tags, token: null, imagePath: thumbnail, source: "solidworks-" + getSWVersion() ); if (form.ShowDialog() == DialogResult.OK && form.ToSaveSummaryInfo) { this.ModelName = form.ModelTitle; this.Description = form.ModelDescription; this.Tags = form.ModelTags; } //*************************************** if (modelType == (int)swDocumentTypes_e.swDocASSEMBLY) { SwApp.SetUserPreferenceToggle ( (int)swUserPreferenceToggle_e.swSTLComponentsIntoOneFile, curOptionValue ); } //File.Delete(thumbnail); File.Delete(tmp_file_path); } catch { } }