private bool ExistProperty(ModelDoc2 model, string prop) { ModelDocExtension swExt = model.Extension; CustomPropertyManager propMgr = swExt.get_CustomPropertyManager(cfgName); object propNames = null; object propTypes = null; object propValues = null; string resol = string.Empty; propMgr.GetAll(ref propNames, ref propTypes, ref propValues); bool has = false; if (propNames != null) { string[] arr = ((string[])propNames); for (int i = 0; i < arr.Length; i++) { if (string.Compare(arr[i], prop, true) == 0) { has = true; break; } } } return(has); }
private void Button_Click_4(object sender, RoutedEventArgs e) { if (swApp == null) { return; } ModelDocExtension swModelExt = swModel.Extension; string exportStepFileName = PARTNAME.Remove(PARTNAME.IndexOf(".")) + ".step"; string fileName = path.Text + @"set\" + exportStepFileName; Directory.CreateDirectory(path.Text + "set"); ExportPdfData exportPdf = default; int Err, Warn; Err = 0; Warn = 0; bool bRet; swModel.ClearSelection2(true); bRet = swApp.SetUserPreferenceIntegerValue((int)swUserPreferenceIntegerValue_e.swStepAP, 214); bRet = swModelExt.SaveAs(fileName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, 0, exportPdf, Err, Warn); if (bRet) { MessageBox.Show("Completed successfully"); } else { MessageBox.Show("export incomplete"); } }
public SwModelWrapper(SwApiWrapper swApi, SldWorks swApp, swDocumentTypes_e swDocType, ModelDoc2 swMainModel, string strConfigName) { this.swApi = swApi; this.swApp = swApp; this.swMainModel = swMainModel; swModelDocExt = (ModelDocExtension)swMainModel.Extension; if (swDocType == swDocumentTypes_e.swDocASSEMBLY) { swMainAssembly = (AssemblyDoc)swMainModel; } if (strConfigName != null) { this.swMainConfig = (Configuration)swMainModel.GetConfigurationByName(strConfigName); } else { this.swMainConfig = (Configuration)swMainModel.GetActiveConfiguration(); } strConfigName = this.swMainConfig.Name; // Write model info to shared variables string[] configsArray = swMainModel.GetConfigurationNames(); this.configNames.AddRange(configsArray); this.configNames.Sort(); this.pathName = swMainModel.GetPathName(); this.modelName = swMainModel.GetTitle(); this.currentConfigName = strConfigName; }
public List <PropertiesClass> ListProperties() { var listString = new List <PropertiesClass>(); _swModelDocExtComp = SwModel.Extension; var propNames = default(object); var propTypes = default(object); var propValues = default(object); _swCustPropMgrComp = _swModelDocExtComp.CustomPropertyManager["00"]; _swCustPropMgrComp.GetAll(ref propNames, ref propTypes, ref propValues); var asCustPropName = (string[])propNames; //var asCustPropValues = (string[])propValues; for (var i = 0; i < asCustPropName.GetUpperBound(0) - 1; i++) { var columnValue = new PropertiesClass { PropertiesName = asCustPropName[i] }; listString.Add(columnValue); } return(listString); }
private String GetRev(ModelDocExtension swModExt) { swCustPropMgr = (CustomPropertyManager)swModExt.get_CustomPropertyManager(""); String[] propNames = (String[])swCustPropMgr.GetNames(); String ValOut = String.Empty; String ResolvedValOut = String.Empty; Boolean WasResolved = false; String result = String.Empty; foreach (String name in propNames) { swCustPropMgr.Get5(name, false, out ValOut, out ResolvedValOut, out WasResolved); if (name.Contains("REVISION") && !name.Contains(@"LEVEL") && ValOut != String.Empty) { result = "-" + ValOut; } } if (result.Length != 3) { MustHaveRevException e = new MustHaveRevException("Check to make sure drawing is at least revision AA or later."); //e.Data.Add("who", System.Environment.UserName); //e.Data.Add("when", DateTime.Now); //e.Data.Add("result", result); throw e; } //System.Diagnostics.Debug.Print(result); return(result); }
public static void InsertBOM(SldWorks swApp) { ModelDoc2 md = (ModelDoc2)swApp.ActiveDoc; DrawingDoc dd = (DrawingDoc)swApp.ActiveDoc; ModelDocExtension ex = (ModelDocExtension)md.Extension; int bom_type = (int)swBomType_e.swBomType_PartsOnly; int bom_numbering = (int)swNumberingType_e.swNumberingType_Flat; int bom_anchor = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft; SolidWorks.Interop.sldworks.View v = GetFirstView(swApp); BomTableAnnotation bta = null; TableAnnotation ta = null; if (dd.ActivateView(v.Name)) { bta = v.InsertBomTable4( false, Properties.Settings.Default.BOMLocationX, Properties.Settings.Default.BOMLocationY, bom_anchor, bom_type, v.ReferencedConfiguration, Properties.Settings.Default.BOMTemplatePath, false, bom_numbering, false); } if (bta != null) { ta = (TableAnnotation)bta; if (ta != null) { int deptcol = 0; List <int> rowdpt = new List <int>(); System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(BOMFilter[0]); for (int i = 0; i < ta.ColumnCount; i++) { if (ta.Text[0, i].ToUpper() == @"DEPTID") { deptcol = i; break; } } for (int i = 0; i < ta.RowCount; i++) { if (!r.IsMatch(ta.Text[i, deptcol])) { rowdpt.Add(i); } } foreach (int item in rowdpt) { ta.set_RowHidden(item, true); } } } }
/// <summary> /// Called when the reset button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ResetButton_Click(object sender, RoutedEventArgs e) { var model = SolidWorksEnvironment.Application.ActiveModel; var model2 = (ModelDoc2)SolidWorksEnvironment.Application.UnsafeObject.ActiveDoc; ModelDocExtension extension = model2.Extension; CustomPropertyManager propertyManager = default(CustomPropertyManager); propertyManager = extension.get_CustomPropertyManager(""); // Remove feature tolerances manually // since there is a variable number of them model.CustomProperties((properties) => { // Find all feature-tolerance custom properties List <CustomProperty> found = properties.FindAll(property => property.Name.Contains(CustomPropertyFeatureTolerance)); // Delete each one foreach (CustomProperty item in found) { propertyManager.Delete(item.Name); } }); mFeatureTolerances.Clear(); FeatureTolerance_Display.Items.Refresh(); RawMaterialList.SelectedIndex = -1; NoteGrid.Children.Clear(); AddNewNote(); }
private void button1_Click(object sender, EventArgs e) { swApp = SolidWorksSingleton.Get_swApp(); swModel = swApp.ActiveDoc; var arquivo = new Arquivo(); int[] codigos = Enumerable.Range(4020128, 2).ToArray(); for (int i = 0; i < codigos.Length - 1; i++) { txtCodigo.Text = codigos[i].ToString(); swApp.OpenDoc(@"C:\ELETROFRIO\ENGENHARIA SMR\PRODUTOS FINAIS ELETROFRIO\MECÂNICA\RACK PADRAO\template_00_rp.SLDASM", (int)swDocumentTypes_e.swDocASSEMBLY); swModel = swApp.ActiveDoc; swView = swModel.ActiveView; swView.EnableGraphicsUpdate = false; // Chamar montador e passar codigo do kit string codigo = codigos[i].ToString(); Montador.MontarKit(codigo); swModel = swApp.ActiveDoc; swExt = swModel.Extension; swApp.DocumentVisible(true, (int)swDocumentTypes_e.swDocASSEMBLY); swApp.DocumentVisible(true, (int)swDocumentTypes_e.swDocPART); string fullPath = @"C:\ELETROFRIO\ENGENHARIA SMR\PRODUTOS FINAIS ELETROFRIO\MECÂNICA\RACK PADRAO\RACK PADRAO TESTE\" + codigo + ".sldasm"; swExt.Rebuild((int)swRebuildOptions_e.swUpdateMates); swModel.SaveAs(fullPath); swApp.CloseDoc(fullPath); } swView.EnableGraphicsUpdate = true; }
private void InsertBOMTable() { ModelDoc2 modelDoc2 = iswApp.ActiveDoc; ModelDocExtension modelDocExtension = modelDoc2.Extension; TableAnnotation tableAnnotation = modelDocExtension.InsertGeneralTableAnnotation(true, 0, 0, (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, @"E:\01_Work\14_Project\材料清单.sldtbt", bomItems.Count + 2, 7); for (int i = 0; i < bomItems.Count; i++) { tableAnnotation.Text[i + 2, 0] = (i + 1).ToString(); tableAnnotation.Text[i + 2, 1] = bomItems[i].name; tableAnnotation.Text[i + 2, 2] = bomItems[i].material; tableAnnotation.Text[i + 2, 3] = bomItems[i].qty.ToString(); tableAnnotation.Text[i + 2, 4] = bomItems[i].comment; } //tableAnnotation.SetColumnWidth(0, 10,0); //foreach (var b in bomItems) //{ // Debug.Print(b.code + "--->" + b.qty.ToString()); //} }
private void btnStart_Click(object sender, EventArgs e) { activeIndex = 0; activeNote = noteList[activeIndex]; haveNextNote = true; // this.Visible = false; swApp = Comm.ConnectToSolidWorks(); swModel = (ModelDoc2)swApp.ActiveDoc; swModelDocExt = swModel.Extension; swModelView = (ModelView)swModel.GetFirstModelView(); TheMouse = swModelView.GetMouse(); mouseClass mouseClass = new mouseClass(this); Frame swFrame = (Frame)swApp.Frame(); swFrame.SetStatusBarText("Next Click to insert " + activeNote); TheMouse.MouseSelectNotify += mouseClass.ms_MouseSelectNotify; Debug.Print("done"); }
// Open "Edit Sketch" and make sketch Normal-To (ctrl+8 shortcut) given the Feature private bool OpenSketchNormalToByName(string sketchName) { // Exit out of any opened sketches if (currentModel.SketchManager.ActiveSketch != null) { currentModel.InsertSketch2(true); } ModelDocExtension swModelDocExt = default(ModelDocExtension); swModelDocExt = currentModel.Extension; bool selected = swModelDocExt.SelectByID2(sketchName, "SKETCH", 0, 0, 0, false, 0, null, 0); if (!selected) { ShowNonFatalError("Failed to select sketch '" + sketchName + "'"); return(false); } // Open sketch for editing ("Edit Sketch" in Solidworks UI) currentModel.EditSketchOrSingleSketchFeature(); // Run the 'Normal-To' view command if (RunNormalToSketchCommand() != 0) { return(false); } return(true); }
public static void GetDocObject(SldWorks iswApp) { StringBuilder sb = new StringBuilder(""); ModelDoc2 SwDoc = iswApp.ActiveDoc;//获得当前激活的文档 sb.Append("文档:" + SwDoc.GetTitle() + "\r\n"); int DocType = SwDoc.GetType(); //获得激活的文档类型 if (DocType == (int)swDocumentTypes_e.swDocPART) //若类型是零件 { PartDoc SwPart = (PartDoc)SwDoc; sb.Append("文档类型:零部件\r\n"); } else if (DocType == (int)swDocumentTypes_e.swDocASSEMBLY)//若类型是装配体 { AssemblyDoc SwAssem = (AssemblyDoc)SwDoc; sb.Append("文档类型:装配体\r\n"); } else if (DocType == (int)swDocumentTypes_e.swDocDRAWING)//若类型是工程图 { DrawingDoc SwAssem = (DrawingDoc)SwDoc; sb.Append("文档类型:工程图\r\n"); } ModelDocExtension SwDocEx = SwDoc.Extension;//获得扩展文档对象 if (SwDocEx != null) { sb.Append("扩展文档:已获得"); } MessageBox.Show(sb.ToString().Trim()); }
/// <summary> /// Called when the apply button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ApplyButton_Click(object sender, RoutedEventArgs e) { var model = SolidWorksEnvironment.Application.ActiveModel; var model2 = (ModelDoc2)SolidWorksEnvironment.Application.UnsafeObject.ActiveDoc; ModelDocExtension extension = model2.Extension; CustomPropertyManager propertyManager = default(CustomPropertyManager); propertyManager = extension.get_CustomPropertyManager(""); // Check if we have a part if (model == null || !model.IsPart) { return; } // Notes // First clear the existing note custom properties model.CustomProperties((properties) => { List <CustomProperty> found = properties.FindAll(property => property.Name.Contains(CustomPropertyNote)); foreach (CustomProperty item in found) { propertyManager.Delete(item.Name); } }); int j = 1; foreach (var child in NoteGrid.Children) { if (child.GetType() == typeof(System.Windows.Controls.TextBox)) { model.SetCustomProperty(CustomPropertyNote + " " + j.ToString(), ((System.Windows.Controls.TextBox)child).Text); j++; } } // Feature Tolerances for (int i = 0; i < mFeatureTolerances.Count; i++) { FeatureToleranceObject item = mFeatureTolerances.ElementAt(i); string CustomPropertyName = CustomPropertyFeatureTolerance + item.FeatureName; model.SetCustomProperty(CustomPropertyName, item.FeatureTolerance); } // If user does not have a material selected, clear it if (RawMaterialList.SelectedIndex < 0) { model.SetMaterial(null); } // Otherwise set the material to the selected one else { model.SetMaterial((Material)RawMaterialList.SelectedItem); } // Re-read details to confirm they are correct ReadDetails(); }
private DrawingDoc CreerPlan(String materiau, Double epaisseur) { String Fichier = String.Format("{0}{1} - Ep{2}", String.IsNullOrWhiteSpace(RefFichier) ? "" : RefFichier + " - ", materiau.eGetSafeFilename("-"), epaisseur.ToString().Replace('.', ',') ).Trim(); if (DicDessins.ContainsKey(Fichier)) { return(DicDessins[Fichier]); } if (MajPlans) { var di = new DirectoryInfo(DossierDVP); var NomFichierExt = Fichier + eTypeDoc.Dessin.GetEnumInfo <ExtFichier>(); var r = di.GetFiles(NomFichierExt, SearchOption.TopDirectoryOnly); if (r.Length > 0) { int Erreur = 0, Warning = 0; DrawingDoc dessin = App.Sw.OpenDoc6(Path.Combine(DossierDVP, NomFichierExt), (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref Erreur, ref Warning).eDrawingDoc(); DicDessins.Add(Fichier, dessin); return(dessin); } } DrawingDoc Dessin = Sw.eCreerDocument(DossierDVP, Fichier, eTypeDoc.Dessin, CONSTANTES.MODELE_DE_DESSIN_LASER).eDrawingDoc(); Dessin.eFeuilleActive().SetName(Fichier); DicDessins.Add(Fichier, Dessin); ModelDoc2 mdl = Dessin.eModelDoc2(); LayerMgr LM = mdl.GetLayerManager(); LM.AddLayer("GRAVURE", "", 1227327, (int)swLineStyles_e.swLineCONTINUOUS, (int)swLineWeights_e.swLW_LAYER); LM.AddLayer("QUANTITE", "", 1227327, (int)swLineStyles_e.swLineCONTINUOUS, (int)swLineWeights_e.swLW_LAYER); ModelDocExtension ext = mdl.Extension; ext.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swFlatPatternOpt_ShowFixedFace, 0, false); ext.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swShowSheetMetalBendNotes, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, AfficherNotePliage); TextFormat tf = ext.GetUserPreferenceTextFormat(((int)(swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat)), 0); tf.CharHeight = TailleInscription / 1000.0; ext.SetUserPreferenceTextFormat((int)swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat, 0, tf); return(Dessin); }
private bool SaveSTEPorEDrw(List <string> fl) { if (fl.Count < 1) { return(false); } int saveVersion = (int)swSaveAsVersion_e.swSaveAsCurrentVersion; int saveOptions = (int)swSaveAsOptions_e.swSaveAsOptions_Silent; int refErrors = 0; int refWarnings = 0; bool success = true; string tmpPath = Path.GetTempPath(); ModelDocExtension swModExt = default(ModelDocExtension); ExportPdfData swExportPDFData = default(ExportPdfData); string fileName = fl[0]; FileInfo fi = new FileInfo(fileName); string tmpFile = tmpPath + "\\" + fi.Name; swModExt = swModel.Extension; bool stepconf = swApp.GetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportConfigurationData); bool stepedgeprop = swApp.GetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportFaceEdgeProps); bool stepsplit = swApp.GetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportSplitPeriodic); bool stepcurve = swApp.GetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExport3DCurveFeatures); int stepAP = swApp.GetUserPreferenceIntegerValue((int)swUserPreferenceIntegerValue_e.swStepAP); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportConfigurationData, true); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportFaceEdgeProps, true); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportSplitPeriodic, true); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExport3DCurveFeatures, false); swApp.SetUserPreferenceIntegerValue((int)swUserPreferenceIntegerValue_e.swStepAP, 203); swFrame.SetStatusBarText(String.Format("Exporting '{0}'", fileName)); success = swModExt.SaveAs(tmpFile, saveVersion, saveOptions, swExportPDFData, ref refErrors, ref refWarnings); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportConfigurationData, stepconf); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportFaceEdgeProps, stepedgeprop); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExportSplitPeriodic, stepsplit); swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swStepExport3DCurveFeatures, stepcurve); swApp.SetUserPreferenceIntegerValue((int)swUserPreferenceIntegerValue_e.swStepAP, stepAP); foreach (string fn in fl) { CopyFile(tmpFile, fn); } if (fl[0].EndsWith(@"EPRT") || fl[0].EndsWith(@"EASM")) { InsertIntoDb(fl[0], Properties.Settings.Default.eDrawingTable); } return(success); }
private void ExportButtonClick(object sender, EventArgs e) { swModelDoc = swApp.ActiveDoc; swModelDocExt = swModelDoc.Extension; swAssDoc = swApp.ActiveDoc as AssemblyDoc; swFeat = (Feature)swModelDoc.FirstFeature(); swFeatMgr = (FeatureManager)swModelDoc.FeatureManager; while ((swFeat != null)) { sFeatType = swFeat.GetTypeName(); if (sFeatType == "CommentsFolder") { swCommentFolder = (CommentFolder)swFeat.GetSpecificFeature2(); nbrComments = swCommentFolder.GetCommentCount(); vComments = (object[])swCommentFolder.GetComments(); for (i = 0; i <= (nbrComments - 1); i++) { swComment = (Comment)vComments[i]; string name = swComment.Name; Component2 comp = swAssDoc.GetComponentByName(name); swModelDocExt.SelectByID2(comp.GetSelectByIDString(), "COMPONENT", 0, 0, 0, false, 0, null, 0); swAssDoc.HideComponent(); } for (i = 0; i <= (nbrComments - 1); i++) { swComment = (Comment)vComments[i]; string name = swComment.Name; Component2 comp = swAssDoc.GetComponentByName(name); swModelDocExt.SelectByID2(comp.GetSelectByIDString(), "COMPONENT", 0, 0, 0, false, 0, null, 0); swAssDoc.ShowComponent(); swModelDocExt.SetUserPreferenceString((int)swUserPreferenceStringValue_e.swFileSaveAsCoordinateSystem, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, "CoordinateSystem"); swModelDocExt.SaveAs("C:/Users/Izmar/Documents/vmpc_models/jan2018/stlexport/" + swComment.Text + ".STL", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, 0, ref errors, ref warnings); swAssDoc.HideComponent(); } for (i = 0; i <= (nbrComments - 1); i++) { swComment = (Comment)vComments[i]; string name = swComment.Name; Component2 comp = swAssDoc.GetComponentByName(name); swModelDocExt.SelectByID2(comp.GetSelectByIDString(), "COMPONENT", 0, 0, 0, false, 0, null, 0); swAssDoc.ShowComponent(); } } // Get next feature in FeatureManager design tree swFeat = (Feature)swFeat.GetNextFeature(); } }
/// <summary> /// 模型打包 /// </summary> /// <param name="suffix">后缀</param> /// <param name="swApp">SW程序</param> /// <param name="modelPath">模型地址</param> /// <param name="itemPath">目标地址</param> /// <returns></returns> public static string PackAndGoFunc(string suffix, SldWorks swApp, string modelPath, string itemPath) { swApp.CommandInProgress = true; int warnings = 0; int errors = 0; ModelDoc2 swModelDoc = default(ModelDoc2); ModelDocExtension swModelDocExt = default(ModelDocExtension); PackAndGo swPackAndGo = default(PackAndGo); //打开需要pack的模型 swModelDoc = (ModelDoc2)swApp.OpenDoc6(modelPath, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); swModelDocExt = (ModelDocExtension)swModelDoc.Extension; swPackAndGo = (PackAndGo)swModelDocExt.GetPackAndGo(); // Get number of documents in assembly //namesCount = swPackAndGo.GetDocumentNamesCount(); //Debug.Print(" Number of model documents: " + namesCount); // Include any drawings, SOLIDWORKS Simulation results, and SOLIDWORKS Toolbox components swPackAndGo.IncludeDrawings = false; swPackAndGo.IncludeSimulationResults = false; swPackAndGo.IncludeToolboxComponents = false; // Set folder where to save the files,目标存放地址 swPackAndGo.SetSaveToName(true, itemPath); //将文件展开到一个文件夹内,不要原始模型的文件夹结构 // Flatten the Pack and Go folder structure; save all files to the root directory swPackAndGo.FlattenToSingleFolder = true; // Add a prefix and suffix to the filenames //swPackAndGo.AddPrefix = "SW_";添加后缀 swPackAndGo.AddSuffix = "_" + suffix; try { // Pack and Go,执行PackAndGo swModelDocExt.SavePackAndGo(swPackAndGo); } catch (Exception ex) { throw new Exception("PackandGo过程中出现异常:" + ex.Message); } finally { swApp.CloseDoc(swModelDoc.GetTitle()); swModelDoc = null; swApp.CommandInProgress = false;//及时关闭外部命令调用,否则影响SolidWorks的使用 } string modelPathName = modelPath.Substring(modelPath.LastIndexOf(@"\") + 1); //返回packandgo后模型的地址 return(itemPath + @"\" + modelPathName.Substring(0, modelPathName.LastIndexOf(".")) + "_" + suffix + ".sldasm"); }
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { this.Close(); } else if (e.Key == Key.S && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl)) { SaveAll(); } else if (e.Key == Key.F5) { SwModel = (ModelDoc2)SwApp.ActiveDoc; if (SwModel != null) { if (((int)SwModel.GetType() != (int)swDocumentTypes_e.swDocPART) && ((int)SwModel.GetType() != (int)swDocumentTypes_e.swDocASSEMBLY)) { MessageBox.Show("当前文件不是零件或装配体文件!"); Environment.Exit(0); } } else { MessageBox.Show("请打开零件或装配体文件!"); Environment.Exit(0); } SwConfigMgr = SwModel.ConfigurationManager; SwModelExt = SwModel.Extension; SwCustPropMgr = SwModelExt.get_CustomPropertyManager(""); string[] configNames = null; configNames = (string[])SwModel.GetConfigurationNames(); CboxConfigName.Items.Clear(); for (int i = 0; i < configNames.Length; i++) { CboxConfigName.Items.Add(configNames[i]); if (configNames[i].Contains(SwConfigMgr.ActiveConfiguration.Name)) { CboxConfigName.Text = SwConfigMgr.ActiveConfiguration.Name; } } DatePickerDesignDate.SelectedDate = DateTime.Today; TextColorReset(); TextBlock.Text = "已成功连接到SolidWorks文件! 按F5重新载入!"; } }
private void InserirPropriedade(Coletor c) { string descricao = ""; descricao += "COL S "; descricao += c.DiametroTuboAcoColetor + "\" "; descricao += c.QuantidadeCompressor + "CP "; descricao += c.DiametroSuccaoCompressor + "\" X "; descricao += c.DiametroSuccaoRack + "\" "; swModel = swApp.ActiveDoc; ConfigurationManager configMgr; configMgr = swModel.ConfigurationManager; Configuration config = configMgr.ActiveConfiguration; string nomeConfig = config.Name; swExt = swModel.Extension; // Deleta prop da custom swCustomMgr = swExt.CustomPropertyManager[""]; string[] nomesProp = null; nomesProp = (string[])swCustomMgr.GetNames(); foreach (var nome in nomesProp) { swCustomMgr.Delete(nome); } // Deleta prop da personalizada swCustomMgr = swExt.CustomPropertyManager[nomeConfig]; nomesProp = null; nomesProp = (string[])swCustomMgr.GetNames(); foreach (var nome in nomesProp) { swCustomMgr.Delete(nome); } swCustomMgr.Add3("DESCRIÇÃO", (int)swCustomInfoType_e.swCustomInfoText, descricao, (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue); swCustomMgr.Add3("PROJETISTA", (int)swCustomInfoType_e.swCustomInfoText, "RICARDO R.", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue); swCustomMgr.Add3("PROJETISTA2D", (int)swCustomInfoType_e.swCustomInfoText, "RICARDO R.", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue); swCustomMgr.Add3("GRUPO ITEM", (int)swCustomInfoType_e.swCustomInfoText, "494", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue); swCustomMgr.Add3("REVISÃO", (int)swCustomInfoType_e.swCustomInfoText, "01", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue); }
private void SaveAs3d(Coletor coletor) { string codigo = coletor.CodigoColetor; string caminhoSalvar = @"C:\ELETROFRIO\ENGENHARIA SMR\PRODUTOS FINAIS ELETROFRIO\MECÂNICA\RACK PADRAO\COLETOR SUCCAO\"; string nomeCompletoArquivo3d = caminhoSalvar + codigo + ".SLDASM"; // Mostra o 3D swApp.ActivateDoc(Path.GetFileName(coletor.ArquivoTemplateDoColetor)); // Ativa o 3D swModel = swApp.ActiveDoc; swExt = swModel.Extension; int retVal = swModel.SaveAs3(nomeCompletoArquivo3d, 0, 0); }
public void Fillcustomproperties() { if (connectapi.Solidworks_running()) { try { const string progId = "SldWorks.Application"; SldWorks swApp = Marshal.GetActiveObject(progId) as SolidWorks.Interop.sldworks.SldWorks; ModelDoc2 swModel; CustomPropertyManager cusPropMgr; int lRetVal; swModel = (ModelDoc2)swApp.ActiveDoc; if (swModel == null) { return; } ModelDocExtension swModelDocExt = swModel.Extension; cusPropMgr = swModelDocExt.get_CustomPropertyManager(""); lRetVal = cusPropMgr.Add3("PartNo", (int)swCustomInfoType_e.swCustomInfoText, list[0], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Description", (int)swCustomInfoType_e.swCustomInfoText, list[1], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("OEM", (int)swCustomInfoType_e.swCustomInfoText, list[3], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("OEM Item Number", (int)swCustomInfoType_e.swCustomInfoText, list[4], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("cDesignedBy", (int)swCustomInfoType_e.swCustomInfoText, designbytxt.Text, (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Heat Treatment", (int)swCustomInfoType_e.swCustomInfoText, list[8], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Surface Protection", (int)swCustomInfoType_e.swCustomInfoText, list[7], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Spare", (int)swCustomInfoType_e.swCustomInfoText, checkBox1.Checked ? "SPARE" : "", (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("JobPlanning", (int)swCustomInfoType_e.swCustomInfoText, "1", (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Notes", (int)swCustomInfoType_e.swCustomInfoText, list[9], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Rupture", (int)swCustomInfoType_e.swCustomInfoText, list[10], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Heat Treatment Req'd", (int)swCustomInfoType_e.swCustomInfoText, heattreat.Text.Length > 0 ? "Checked" : "Unchecked", (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Surface Protection Req'd", (int)swCustomInfoType_e.swCustomInfoText, surfacetxt.Text.Length > 0 ? "Checked" : "Unchecked", (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("Family Type", (int)swCustomInfoType_e.swCustomInfoText, list[6], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); lRetVal = cusPropMgr.Add3("cCategory", (int)swCustomInfoType_e.swCustomInfoText, list[5], (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd); string category = connectapi.Getfamilycategory(familycombobox.SelectedItem.ToString()); if (string.Equals(category, "manufactured", StringComparison.CurrentCultureIgnoreCase)) { PartDoc swPart = (PartDoc)swModel; swPart.SetMaterialPropertyName2("Default", "//SPM-ADFS/CAD Data/CAD Templates SPM/SPM.sldmat", mattxt.Text); } bool boolstatus = swModel.Save3((int)swSaveAsOptions_e.swSaveAsOptions_Silent, 0, 0); } catch (Exception ex) { MessageBox.Show(ex.Message, "SPM Connect New Item Fill Custom Properties", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void button1_Click(object sender, EventArgs e) { if (this.connectToSolidWorks()) { // get the path to the example part String path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Example.SLDPRT"); if (File.Exists(path)) { // open the example part in solidworks int errors = 0; ModelDoc2 swModel = swApp.OpenDoc2(path, (int)swDocumentTypes_e.swDocPART, true, false, true, ref errors); if (swModel != null) { PartDoc partDoc = (PartDoc)swModel; // get the solid bodies in the part var bodies = partDoc.GetBodies2((int)swBodyType_e.swSolidBody, false); ModelDocExtension swModExt = (ModelDocExtension)swModel.Extension; // iterate through each solid body and delete any hidden solidbodies foreach (Body2 body in bodies) { if (!body.Visible) { swModExt.SelectByID2(body.Name, "SOLIDBODY", 0, 0, 0, false, 0, null, 0); swModel.FeatureManager.InsertDeleteBody(); swModel.ClearSelection(); } } // export the result String desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); int warnings = 0; swModExt.SaveAs(Path.Combine(desktopPath, "Result.step"), 0, 0, null, ref errors, ref warnings); swApp.CloseAllDocuments(true); } } this.releaseSolidWorks(); } else { MessageBox.Show("Error starting SolidWorks."); } }
private void InitTableData() { md = (ModelDoc2)DrawingPropertySet.SwApp.ActiveDoc; mde = md.Extension; fracdisp = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); //int den = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearFractionDenominator, // (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decs = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decd = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); try { mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, (int)swFractionDisplay_e.swDECIMAL); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); md.ForceRebuild3(false); table = new swTableType.swTableType((DrawingPropertySet.SwApp.ActiveDoc as ModelDoc2), Redbrick.MasterHashes); } catch (NullReferenceException nre) { if (_swApp != null) { if (dept > -1) { Redbrick.InsertBOM(_swApp, dept); } else { Redbrick.InsertBOM(_swApp); } InitTableData(); } else { throw new NullReferenceException(@"No table found."); } } catch (Exception e) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(e); em.ShowDialog(); Close(); } finally { // } }
public Boolean ExportMetalPdfs() { String pdfSourceName = Path.GetFileNameWithoutExtension(drawingPath); String pdfAltPath = Path.GetDirectoryName(drawingPath).Substring(44); //String pdfAltPath = ".\\"; String fFormat = String.Empty; ModelDocExtension swModExt = swModel.Extension; List <String> pdfTarget = new List <string>(); pdfTarget.Add(String.Format("{0}{1}\\{2}.PDF", APathSet.MetalPath, pdfAltPath, pdfSourceName)); Boolean success = SaveFiles(pdfTarget); return(success); }
private void Reset() { SwApp = new SldWorks(); if (SwApp == null) { MessageBox.Show("未找到已启动的Solidworks主程序!"); Environment.Exit(0); } SwApp.Visible = true; SwModel = (ModelDoc2)SwApp.ActiveDoc; if (SwModel != null) { if (((int)SwModel.GetType() != (int)swDocumentTypes_e.swDocPART) && ((int)SwModel.GetType() != (int)swDocumentTypes_e.swDocASSEMBLY)) { MessageBox.Show("当前文件不是零件或装配体文件!"); Environment.Exit(0); } } else { MessageBox.Show("请打开零件或装配体文件!"); Environment.Exit(0); } SwConfigMgr = SwModel.ConfigurationManager; SwModelExt = SwModel.Extension; SwCustPropMgr = SwModelExt.get_CustomPropertyManager(""); string[] configNames = null; configNames = (string[])SwModel.GetConfigurationNames(); CboxConfigName.Items.Clear(); for (int i = 0; i < configNames.Length; i++) { CboxConfigName.Items.Add(configNames[i]); if (configNames[i].Contains(SwConfigMgr.ActiveConfiguration.Name)) { //cboxConfigName.SelectedIndex = i; CboxConfigName.Text = SwConfigMgr.ActiveConfiguration.Name; } } DatePickerDesignDate.SelectedDate = DateTime.Today; TextColorReset(); TextBlock.Text = "已成功连接到SolidWorks文件! 按F5重新载入!"; }
private void SaveAsTubo(Coletor coletor) { string codigo = coletor.CodigoTuboAcoColetor; string caminhoSalvar = @"C:\ELETROFRIO\ENGENHARIA SMR\PRODUTOS FINAIS ELETROFRIO\MECÂNICA\RACK PADRAO\COLETOR SUCCAO\"; string nomeCompletoArquivo3d = caminhoSalvar + codigo + ".SLDPRT"; // Mostra o 3D swApp.ActivateDoc(coletor.ArquivoTemplateTuboDoColetor); // Ativa o 3D swModel = swApp.ActiveDoc; swExt = swModel.Extension; int retVal = swModel.SaveAs3(nomeCompletoArquivo3d, 0, 0); AlterarDimensao(coletor); }
public static void GetFace(ModelDoc2 Doc) { ModelDocExtension DocEx = Doc.Extension; SelectionMgr SwSelMrg = Doc.SelectionManager; DocEx.SelectByID2("", "FACE", -100 / 1000.0, 60 / 1000.0, 15 / 1000.0, false, -1, null, 0); System.Windows.MessageBox.Show("模拟选中面"); string selcount = SwSelMrg.GetSelectedObjectCount2(-1).ToString(); swSelectType_e seltype = (swSelectType_e)SwSelMrg.GetSelectedObjectType3(1, -1); if (seltype == swSelectType_e.swSelFACES) { Face2 SwFace = SwSelMrg.GetSelectedObject6(1, -1); System.Windows.MessageBox.Show("选中数:" + selcount + "\r\n选中类型:" + seltype.ToString() + "\r\n选中面面积:" + SwFace.GetArea().ToString()); } }
public static void MeasureFace(ModelDoc2 Doc) { ModelDocExtension DocEx = Doc.Extension; SelectionMgr SwSelMrg = Doc.SelectionManager; Measure SwMeasure = DocEx.CreateMeasure(); DocEx.SelectByID2("", "FACE", -100 / 1000.0, 60 / 1000.0, 15 / 1000.0, false, -1, null, 0); DocEx.SelectByID2("", "FACE", 100 / 1000.0, 60 / 1000.0, 15 / 1000.0, true, -1, null, 0); Face2 SwFace1 = SwSelMrg.GetSelectedObject6(1, -1); Face2 SwFace2 = SwSelMrg.GetSelectedObject6(2, -1); Entity[] ents = new Entity[] { (Entity)SwFace1, (Entity)SwFace2 }; SwMeasure.Calculate(ents); System.Windows.MessageBox.Show("中心距:" + (SwMeasure.CenterDistance * 1000).ToString().Trim() + "mm"); }
/// <summary> /// 添加尺寸 /// </summary> /// <param name="dimensionType">添加尺寸类型</param> /// <param name="swDrawDoc"></param> /// <param name="swModel"></param> private void AddDimension(string dimensionType, DrawingDoc swDrawDoc, ModelDoc2 swModel) { ModelDocExtension swModelDocExt = (ModelDocExtension)swModel.Extension; //swDrawDoc.AutoDimension((int)swAutodimEntities_e.swAutodimEntitiesBasedOnPreselect, (int)swAutodimScheme_e.swAutodimSchemeBaseline, (int)swAutodimHorizontalPlacement_e.swAutodimHorizontalPlacementAbove, (int)swAutodimScheme_e.swAutodimSchemeBaseline, (int)swAutodimVerticalPlacement_e.swAutodimVerticalPlacementRight); if (addDimensionNo) { return; } else if (addDimensionAuto) { _currentSheet = (Sheet)swDrawDoc.GetCurrentSheet(); swDrawDoc.ActivateSheet(_currentSheet.GetName()); //swDrawDoc.AutoDimension((int)swAutodimEntities_e.swAutodimEntitiesBasedOnPreselect, (int)swAutodimScheme_e.swAutodimSchemeBaseline, (int)swAutodimHorizontalPlacement_e.swAutodimHorizontalPlacementAbove, (int)swAutodimScheme_e.swAutodimSchemeBaseline, (int)swAutodimVerticalPlacement_e.swAutodimVerticalPlacementRight); object[] array3 = (object[])swDrawDoc.InsertModelAnnotations3((int)swImportModelItemsSource_e.swImportModelItemsFromEntireModel, (int)swInsertAnnotation_e.swInsertDimensionsMarkedForDrawing, true, true, false, false); } }
public static void GetEdge(ModelDoc2 Doc) { ModelDocExtension DocEx = Doc.Extension; SelectionMgr SwSelMrg = Doc.SelectionManager; DocEx.SelectByID2("", "EDGE", 0 / 1000.0, 30 / 1000.0, 75 / 1000.0, false, -1, null, 0); System.Windows.MessageBox.Show("模拟选中边线"); string selcount = SwSelMrg.GetSelectedObjectCount2(-1).ToString(); swSelectType_e seltype = (swSelectType_e)SwSelMrg.GetSelectedObjectType3(1, -1); if (seltype == swSelectType_e.swSelEDGES) { Edge SwEdge = SwSelMrg.GetSelectedObject6(1, -1); SwEdge.Display(1, 1, 0, 0, true);//true变色开,false关闭变色 System.Windows.MessageBox.Show("选中数:" + selcount + "\r\n选中类型:" + seltype.ToString() + "\r\n选中边已变色"); } }
private void InitTableData() { md = (ModelDoc2)DrawingPropertySet.SwApp.ActiveDoc; mde = md.Extension; fracdisp = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); //int den = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearFractionDenominator, // (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decs = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decd = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); try { mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, (int)swFractionDisplay_e.swDECIMAL); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); md.ForceRebuild3(false); table = new swTableType.swTableType((DrawingPropertySet.SwApp.ActiveDoc as ModelDoc2), Redbrick.MasterHashes); } catch (NullReferenceException nre) { if (_swApp != null) { Redbrick.InsertBOM(_swApp); InitTableData(); } else { throw new NullReferenceException(@"No table found."); } } catch (Exception e) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(e); em.ShowDialog(); Close(); } finally { // } }
public void OpenDoc(int idPdm, int revision, int taskType, string filePath, string fileName) { swApp = new SldWorks() {Visible = true}; Process[] processes = Process.GetProcessesByName("SLDWORKS"); var errors = 0; var warnings = 0; #region Case switch (taskType) { case 1: Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectionColor = Color.Black)); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += (String.Format("Выполняется: {0}\r\n", filePath)))); swModel = swApp.OpenDoc6(filePath, (int) swDocumentTypes_e.swDocPART, (int) swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); swModel = swApp.ActiveDoc; if (!IsSheetMetalPart((IPartDoc) swModel)) { Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectionColor = Color.DarkBlue)); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += ("Не листовой металл!\r\n"))); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += ("--------------------------------------------------------------------------------------------------------------\r\n"))); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += ("\r\n"))); swApp.CloseDoc(filePath); swApp.ExitApp(); swApp = null; foreach (Process process in processes) { process.CloseMainWindow(); process.Kill(); } return; } swExtension = (ModelDocExtension) swModel.Extension; swModel.EditRebuild3(); swModel.ForceRebuild3(false); CreateFlattPatternUpdate(); object[] confArray = swModel.GetConfigurationNames(); foreach (var confName in confArray) { Configuration swConf = swModel.GetConfigurationByName(confName.ToString()); if (swConf.IsDerived()) continue; Area(confName.ToString()); GabaritsForPaintingCamera(confName.ToString()); } ExportDataToXmlSql(fileName, idPdm, revision); ConvertToErpt(filePath); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectionColor = Color.Black)); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += (String.Format("{0} - Выполнен!\r\n", filePath)))); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += ("-----------------------------------------------------------------\r\n"))); Program.HostForm.richTextBoxLog.Invoke(new Action(() => Program.HostForm.richTextBoxLog.SelectedText += ("\r\n"))); break; case 2: swModel = swApp.OpenDoc6(filePath, (int) swDocumentTypes_e.swDocDRAWING, (int) swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); //if (warnings == (int)swFileLoadWarning_e.swFileLoadWarning_ReadOnly) //{MessageBox.Show("This file is read-only.");} swDraw = (DrawingDoc) swModel; swExtension = (ModelDocExtension) swModel.Extension; ConvertToPdf(filePath); break; case 3: //swModel = swApp.OpenDoc6(filePath, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); MessageBox.Show("3"); break; } //TODO: swApp exit swApp.CloseDoc(filePath); swApp.ExitApp(); swApp = null; foreach (Process process in processes) { process.CloseMainWindow(); process.Kill(); } #endregion }