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; }
private void b_analyze_Click(object sender, EventArgs e) { // Entleeren der ListBox lb_output.Items.Clear(); ModelDoc2 swModel = swApp.ActiveDoc; Configuration ACTC = swModel.GetActiveConfiguration(); Component2 root = ACTC.GetRootComponent(); // Verbindung zu Excel herstellen exlApp = new Microsoft.Office.Interop.Excel.Application(); exlApp.Visible = true; // neues Worksheet anlegen exlBook = exlApp.Workbooks.Add(); exlSheet = exlBook.ActiveSheet; // Tabbelkopf anlegen exlSheet.Cells[1, 1] = "Menge"; exlSheet.Cells[1, 2] = "Einheit"; exlSheet.Cells[1, 3] = "Name"; exlSheet.Cells[1, 4] = "Bemerkung"; // calling traverse Methode traverse(root); }
public void PurgeUnused() { ModelDoc2 swModel = iSwApp.ActiveDoc; Configuration swConf = swModel.GetActiveConfiguration(); var cfgNames = swModel.GetConfigurationNames(); ConfigurationManager swCfgMgr = swModel.ConfigurationManager; Component2 swRootComp = swConf.GetRootComponent3(true); Boolean bRet = true; int i; string configName = ""; object ConfigValues = new object(); object ConfigParams = new object(); var vChildComp = swRootComp.GetChildren(); for (i = 0; i <= vChildComp.GetUpperBound(0); i++) { Component2 swChildComp = vChildComp[i]; bRet = swCfgMgr.GetConfigurationParams(configName, out ConfigParams, out ConfigValues); //if (swChildComp.GetSuppression() == 0) //{ // MessageBox.Show(swChildComp.Name2 + " is suppressed"); // swChildComp.Select(true); // swModel.EditDelete(); //} } }
public static void CustFromModelToDRW() { if (docType != swDocumentTypes_e.swDocDRAWING) { swModel = swApp.ActiveDoc;; EditProp.configuracione = swModel.GetActiveConfiguration().Name; } }
public static void Add(SldWorks swApp, ModelDoc2 parentDoc) { swApp.ActivateDoc(parentDoc.GetTitle()); var configuration = ((Configuration)parentDoc.GetActiveConfiguration()).Name; var swCustProp = parentDoc.Extension.CustomPropertyManager[configuration]; AddProperty(swCustProp, new KeyValuePair <string, string> ("Наименование", "Новое наименование")); }
public static void GetSolidObject() { swApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application"); swModel = swApp.ActiveDoc; docType = (swDocumentTypes_e)swModel.GetType(); configName = swModel.GetActiveConfiguration().Name;//при первом вызове присваеваеться активная конфигурация Class.configNames = Class.GetAllConfigurations(out lockForConf); }
public static void AddAll(SldWorks swApp, ModelDoc2 parentDoc, List <KeyValuePair <string, string> > properties) { swApp.ActivateDoc(parentDoc.GetTitle()); var configuration = ((Configuration)parentDoc.GetActiveConfiguration()).Name; var swCustProp = parentDoc.Extension.CustomPropertyManager[configuration]; foreach (var property in properties) { AddProperty(swCustProp, property); } }
public static void AddAll(SldWorks swApp, ModelDoc2 parentDoc, List <KeyValuePair <string, string> > properties) { swApp.ActivateDoc(parentDoc.GetTitle()); var configuration = ((Configuration)parentDoc.GetActiveConfiguration()).Name; MessageBox.Show("configuration - " + configuration); var swCustProp = parentDoc.Extension.CustomPropertyManager[configuration]; foreach (var property in properties) { MessageBox.Show(property.Key + " - " + property.Value, "Свойство для добавления"); AddProperty(swCustProp, property); } }
/// <summary> /// 读取当前装配的BOM 清单 /// /// </summary> private void GetBOMList() { ModelDoc2 swModel = iswApp.ActiveDoc; if (swModel.GetType() == 2) { Configuration swConf = (Configuration)swModel.GetActiveConfiguration(); Component2 swRootComp = (Component2)swConf.GetRootComponent3(false); //OutputCompXform(swRootComp, 0); OutputCompXformTemp(swRootComp, 0, ""); } else { //MessageBox.Show("BOM功能只适用于装配体."); } }
public void GetParametersFromAssembly(ModelDoc2 doc, ref List <ModelDoc2> Parameters_List) { if (doc == null) { return; } int docType = doc.GetType(); if (docType == (int)swDocumentTypes_e.swDocPART) { Parameters_List.Add(doc); return; } //object haha = doc.get; Configuration swConf = (Configuration)doc.GetActiveConfiguration(); if (swConf == null) { return; } Component2 swRootComp = (Component2)swConf.GetRootComponent(); int swRootComp1 = (int)swConf.GetParameterCount(); if (swRootComp1 == null) { return; } else { Parameters_List.Add(doc); object[] haha = swRootComp.GetChildren(); foreach (object hh in haha) { Component2 hh2 = (Component2)hh; ModelDoc2 hhhh = hh2.GetModelDoc2(); GetParametersFromAssembly(hhhh, ref Parameters_List); } } }
private void btnGetIntersectionPoint_Click(object sender, EventArgs e) { AllBodies.Clear(); ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc; if (swModel == null) { MessageBox.Show("请先打开装配体"); return; } if (swModel.GetType() != (int)swDocumentTypes_e.swDocASSEMBLY) { MessageBox.Show("请先打开装配体"); return; } swApp.CommandInProgress = true; if (swApp != null) { Configuration swConf = (Configuration)swModel.GetActiveConfiguration(); Component2 swRootComp = (Component2)swConf.GetRootComponent(); //遍历 TraverseCompXform(swRootComp, 0); } //if (AllBodies.Count > 0) //{ // MessageBox.Show(AllBodies.Count.ToString()); //} CreatePoints(); swApp.CommandInProgress = false; }
public static void GetActualDoc(string[] Args) { try { foreach (string Arg in Args) { switch (Arg) { case "modeldoc": modeldoc = (ModelDoc2)App.ActiveDoc; break; case "assemblyDoc": assemblyDoc = (AssemblyDoc)App.ActiveDoc; break; case "configuration": configuration = (Configuration)modeldoc.GetActiveConfiguration(); break; case "iComponent": iComponent = (IComponent2)configuration.GetRootComponent(); break; //case "Child": // iComponent = (IComponent2)configuration.GetRootComponent(); // break; } } } catch (Exception ex) { //KKS.KKS_Message.Show(ex.Message); } //return modeldoc; }
private bool GetComponentByName(ModelDoc2 inModel, string inName, bool isDropSuffix, out Component2 outComponent, bool isGetSubComponents) { var swComponents = new LinkedList<Component2>(); bool ret = false; outComponent = null; var swConfig = (Configuration)inModel.GetActiveConfiguration(); if (swConfig != null) { var swRootComponent = (Component2)swConfig.GetRootComponent(); if (GetComponents(swRootComponent, swComponents, isGetSubComponents, false)) { foreach (Component2 comp in swComponents) { string compName = isDropSuffix ? GetComponentNameWithoutSuffix(comp.Name2) : comp.Name2; if (compName.ToLower() == inName.ToLower()) { outComponent = comp; ret = true; break; } } } } return ret; }
public static void GetSolidObject() { swApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application"); swModel = swApp.ActiveDoc; // Проверка открытого документа if (swModel == null) { swApp.SendMsgToUser2("Откройте модель, сборку или чертеж!", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); return; } if (string.IsNullOrEmpty(swModel.GetPathName())) { swApp.SendMsgToUser2("Сохраните файл!", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); return; } docType = (swDocumentTypes_e)swModel.GetType(); if (docType != swDocumentTypes_e.swDocDRAWING) { configName = swModel.GetActiveConfiguration().Name;//при первом вызове присваеваеться активная конфигурация EditProp.configNames = EditProp.GetAllConfigurations(); } else { #region Если открыт чертеж lockForConf = true;//нельзя изменить конфигурацию на формочке drw = (DrawingDoc)swModel; // Получение первого листа Sheet swSheet = drw.GetCurrentSheet(); Propertiy.Format = GetFormat(swSheet); Propertiy.Sheets = drw.GetSheetCount().ToString(); Propertiy.Sheet = swSheet.GetName(); // Узнаем имя активного листа string[] vSheetNames = drw.GetSheetNames(); drw.ActivateSheet(vSheetNames[0]); swSheet = drw.GetCurrentSheet(); swView = drw.GetFirstView(); Propertiy.Scale = swView.ScaleRatio[0].ToString() + ":" + swView.ScaleRatio[1].ToString(); m = 0; if (swSheet.CustomPropertyView == "По умолчанию" | swSheet.CustomPropertyView == "Default") { // Получаем первый вид swView = swView.GetNextView(); } else { while (swView != null) { if (swView.GetName2() == swSheet.CustomPropertyView) { m = 1; } swView = swView.GetNextView(); } if (m == 0) { swView = drw.GetFirstView(); swView = swView.GetNextView(); swApp.SendMsgToUser2("Не удалось определить вид из свойств листа. Ипользуется первый вид.", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } } if (swView == null) { swApp.SendMsgToUser2("Отсутсвует модель!", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); // Возвращение активного листа drw.ActivateSheet(Propertiy.Sheet); return; } if (swView.ReferencedDocument == null) { swApp.SendMsgToUser2("Отсутсвует модель!", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); // Возвращение активного листа drw.ActivateSheet(Propertiy.Sheet); return; } #endregion } }
/// <summary> /// 天花子装配导出DXF图纸 /// </summary> /// <param name="swApp"></param> /// <param name="tree"></param> /// <param name="dxfPath"></param> /// <param name="userId"></param> public void CeilingAssyToDxf(SldWorks swApp, SubAssy subAssy, string dxfPath, int userId) { swApp.CommandInProgress = true; List <CeilingCutList> celingCutLists = new List <CeilingCutList>(); string assyPath = subAssy.SubAssyPath; if (assyPath.Length == 0) { return; } try { //打开模型 ModelDoc2 swModel = swApp.OpenDoc6(assyPath, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings) as ModelDoc2; if (swModel == null) { MessageBox.Show("模型不存在,请认真检查", "模型不存在"); return; } string modulePath = dxfPath + @"\" + subAssy.SubAssyName; if (!Directory.Exists(modulePath)) { Directory.CreateDirectory(modulePath); } swModel.ForceRebuild3(true); AssemblyDoc swAssy = swModel as AssemblyDoc; //获取所有零部件集合 var compList = swAssy.GetComponents(false); //遍历集合中的所有零部件对象 foreach (var swComp in compList) { //判断零件是否被压缩,不显示,封套,零件名称不是以sldprt或SLDPRT结尾 if (swComp.Visible == 1 && !swComp.IsEnvelope() && !swComp.IsSuppressed() && (swComp.GetPathName().EndsWith(".sldprt") || swComp.GetPathName().EndsWith(".SLDPRT"))) { Component2 swParentComp = swComp.GetParent(); //总装没有父装配体 if (swParentComp == null) { ConfigurationManager swConfigMgr = swModel.ConfigurationManager; Configuration swConfig2 = swConfigMgr.ActiveConfiguration; swParentComp = swConfig2.GetRootComponent3(true); } //判断父装配体是否可视,并且不封套 if (swParentComp.Visible == 1 && !swParentComp.IsEnvelope() && !swComp.IsSuppressed()) { PartDoc swPart = swComp.GetModelDoc2(); //获取文档中的额Body对象集合 var bodyList = swPart.GetBodies2(0, false); //遍历集合中的所有Body对象,判断是否为钣金 foreach (var swBody in bodyList) { //如果是钣金则将零件地址添加到列表中 if (swBody.IsSheetMetal()) { if (sheetMetaDic.ContainsKey(swComp.GetPathName())) { sheetMetaDic[swComp.GetPathName()] += 1; } else { sheetMetaDic.Add(swComp.GetPathName(), 1); } } } } } } //关闭装配体零件 swApp.CloseDoc(assyPath); //遍历钣金零件 foreach (var sheetMeta in sheetMetaDic) { //打开模型 ModelDoc2 swPart = swApp.OpenDoc6(sheetMeta.Key, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings) as ModelDoc2; Feature swFeat = (Feature)swPart.FirstFeature(); CeilingCutList cutRecord = new CeilingCutList() { SubAssyId = subAssy.SubAssyId, Quantity = sheetMeta.Value, UserId = userId }; while (swFeat != null) { var suppStatus = swFeat.IsSuppressed2((int)swInConfigurationOpts_e.swThisConfiguration, null); if (suppStatus[0] == false && swFeat.GetTypeName() == "SolidBodyFolder") { BodyFolder swBodyFolder = (BodyFolder)swFeat.GetSpecificFeature2(); swBodyFolder.SetAutomaticCutList(true); swBodyFolder.SetAutomaticUpdate(true); Feature SubFeat = swFeat.GetFirstSubFeature(); if (SubFeat != null) { Feature ownerFeature = SubFeat.GetOwnerFeature(); BodyFolder swSubBodyFolder = ownerFeature.GetSpecificFeature2(); swSubBodyFolder.UpdateCutList(); string val = string.Empty; string valout = string.Empty; bool wasResolved = false; bool linkToProp = false; SubFeat.CustomPropertyManager.Get4("Bounding Box Length", false, out val, out valout); cutRecord.Length = Convert.ToDecimal(valout); SubFeat.CustomPropertyManager.Get4("Bounding Box Width", false, out val, out valout); cutRecord.Width = Convert.ToDecimal(valout); SubFeat.CustomPropertyManager.Get4("Sheet Metal Thickness", false, out val, out valout); cutRecord.Thickness = Convert.ToDecimal(valout); SubFeat.CustomPropertyManager.Get4("Material", false, out val, out valout); cutRecord.Materials = valout; swPart.GetActiveConfiguration().CustomPropertyManager.Get6("Description", false, out valout, out val, out wasResolved, out linkToProp); cutRecord.PartDescription = valout; cutRecord.PartNo = swPart.GetTitle().Substring(0, swPart.GetTitle().Length - 7); celingCutLists.Add(cutRecord);//将信息添加到集合中 } } swFeat = swFeat.GetNextFeature(); } PartToDxf(swApp, swPart, modulePath); //关闭零件 swApp.CloseDoc(sheetMeta.Key); } } catch (Exception ex) { throw new Exception(assyPath + "导图过程发生异常,详细:" + ex.Message); } finally { sheetMetaDic.Clear(); swApp.CloseDoc(assyPath); //关闭,很快 swApp.CommandInProgress = false; //及时关闭外部命令调用,否则影响SolidWorks的使用 } //基于事务ceilingCutLists提交SQLServer if (celingCutLists.Count == 0) { return; } try { if (objCeilingCutListService.ImportCutList(celingCutLists)) { celingCutLists.Clear(); } } catch (Exception ex) { throw new Exception("Cutlist导入数据库失败" + ex.Message); } }
private bool HideCompAndShowCross(ModelDoc2 swModel, string f1, string f2, out string comp1Name, out string comp2Name, out List<Component2> list) { bool ret = false; Component2 swComp1, swComp2; list = new List<Component2>(); comp1Name = " "; comp2Name = " "; if (GetComponentByName(swModel, f1, false, out swComp1) && GetComponentByName(swModel, f2, false, out swComp2)) { var swComponents = new LinkedList<Component2>(); comp1Name = swComp1.Name; comp2Name = swComp2.Name; if (comp1Name != comp2Name) { var swConfig = (Configuration)swModel.GetActiveConfiguration(); if (swConfig != null) { var swRootComponent = (Component2)swConfig.GetRootComponent(); if (GetComponents(swRootComponent, swComponents, false, false)) { foreach (var component in swComponents) { if ((component.Name != swComp1.Name) && (component.Name != swComp2.Name) && (component.Visible == 1)) { component.Select(false); swModel.HideComponent2(); swModel.ClearSelection(); list.Add(component); ret = true; } } return ret; } } } } return false; }
private bool GetSymilarComponentByName(ModelDoc2 inModel, string inName, out Component2 outComponent) { var swComponents = new LinkedList<Component2>(); bool ret = false; outComponent = null; var swConfig = (Configuration)inModel.GetActiveConfiguration(); if (swConfig != null) { var swRootComponent = (Component2)swConfig.GetRootComponent(); if (GetComponents(swRootComponent, swComponents, false, false)) { foreach (Component2 comp in swComponents) { string compName = comp.Name2; if (compName.ToLower().Contains(inName.ToLower())) { outComponent = comp; ret = true; break; } } } } return ret; }
//To load an assembly model public static Component2 GetRootComponent(SldWorks swApplication, ModelDoc2 swModel) { Component2 swRootComponent = null; swModel = swApplication.ActiveDoc; var swSafeEntityList = new List <object>(); var modelType = swModel.GetTitle(); var documentType = (swDocumentTypes_e)swModel.GetType(); if (documentType == swDocumentTypes_e.swDocASSEMBLY) { var assemblyModel = (AssemblyDoc)swModel; var configuration = (Configuration)swModel.GetActiveConfiguration(); swRootComponent = configuration.GetRootComponent(); #region FACE ID SET (not used) //QUESTA PARTE SERVIVA PER SETTARE L'ID DELLE FACCE // (NON FUNZIONA SE UNA DELLE COMPONENTI è UN SOTTOASSEMBLATO, PRENDE TUTTE // LE COMPONENTI DEL 1° LIVELLO) //var listComponents = (Array)assemblyModel.GetComponents(true); //swApplication.SendMsgToUser("Ho scomposto il model in componenti. NUmero compo: " + listComponents.Length); //foreach (Component2 component in listComponents) //{ //var bodies = (Array)component.GetBodies2((int)swBodyType_e.swAllBodies); //swApplication.SendMsgToUser("numero body " + bodies.Length.ToString()); // foreach (Body2 body in bodies) // { // // var procBody = body.GetProcessedBodyWithSelFace(); // // var swFace = (Face2)procBody.GetFirstSelectedFace(); // var swFace = (Face2) body.GetFirstFace(); // while (swFace != null) // { // // swApplication.SendMsgToUser("C'è un faccia "); // var idNode = swFace.GetHashCode(); // swFace.SetFaceId(idNode); // swFace = swFace.GetNextFace(); // } // } //} //QUESTA PARTE SERVIVA PER SALVARE LE FACCE SELEZIONATE CON CLICK // var mySelManager = (SelectionMgr)swModel.SelectionManager; // var selectionCount = mySelManager.GetSelectedObjectCount2(-1); // //swApplication.SendMsgToUser("Numero oggetti selezionati " + selectionCount.ToString()); // for (int i = 0; i < selectionCount; i++) // { // var myFace = (Face2)mySelManager.GetSelectedObject6(i + 1, -1); // // var idNode = myFace.GetHashCode(); // // myFace.SetFaceId(idNode); // listFace.Add(myFace); // var swEntity = ((Entity)myFace).GetSafeEntity(); // var swSafeEntity = (Entity)swEntity.GetSafeEntity(); // swSafeEntityList.Add(swSafeEntity); // } #endregion } return(swRootComponent); }
public bool SetAsmUnit(ModelDoc2 model, out LinkedList<Component2> swComps) { bool ret = false; Configuration swConfig; swComps = new LinkedList<Component2>(); try { SetModelProperty(model, "AsmUnit", "", swCustomInfoType_e.swCustomInfoText, model.GetPathName()); swConfig = (Configuration)model.GetActiveConfiguration(); if (swConfig != null) { var swRootComponent = (Component2)swConfig.GetRootComponent(); if (GetComponents(swRootComponent, swComps, true, false)) { foreach (var component2 in swComps) { var mod = component2.IGetModelDoc(); if (mod != null) { bool isIndependent = (!string.IsNullOrEmpty(mod.GetCustomInfoValue("", "IsIndependent") as string) && mod.GetCustomInfoValue("", "IsIndependent") == "Yes"); if (isIndependent) { SetModelProperty(mod, "AsmUnit", "", swCustomInfoType_e.swCustomInfoText, RootModel.GetPathName()); } else { var swParentComp = component2.GetParent(); string val = swParentComp == null ? model.GetPathName() : swParentComp.GetPathName(); SetModelProperty(mod, "AsmUnit", "", swCustomInfoType_e.swCustomInfoText, val); } } } ret = true; } } } catch { } return ret; }
public bool GetAllUniqueModels(ModelDoc2 inModel, out LinkedList<ModelDoc2> outModels) { Configuration swConfig; var swComponents = new LinkedList<Component2>(); bool ret = false; outModels = new LinkedList<ModelDoc2>(); try { outModels.AddLast(inModel); swConfig = (Configuration)inModel.GetActiveConfiguration(); if (swConfig != null) { var swRootComponent = (Component2)swConfig.GetRootComponent(); if (GetComponents(swRootComponent, swComponents, true, false)) { foreach (Component2 comp in swComponents) { var swCompModel = (ModelDoc2)comp.GetModelDoc(); if (swCompModel != null) { ModelDoc2 model = swCompModel; bool isModelAlreadyAdded = outModels.Any(mdoc => mdoc.GetPathName() == model.GetPathName()); if (!isModelAlreadyAdded) outModels.AddLast(swCompModel); } } } } ret = true; } catch { } return ret; }
/// <summary> /// Opens and saves models referenced in the open drawing. /// </summary> /// <returns>Returns a <see cref="System.Boolean"/>, should you need one.</returns> public Boolean ExportEDrawings() { ModelDoc2 currentDoc = swModel; string docName = currentDoc.GetPathName(); String sourceName = Path.GetFileNameWithoutExtension(docName); String altPath = Path.GetDirectoryName(docName).Substring(3); ModelDocExtension swModExt = swModel.Extension; String Rev = GetRev(swModExt); String fFormat = String.Empty; List <string> ml = get_list_of_open_docs(); List <String> EdrwTarget = new List <string>(); List <String> STEPTarget = new List <string>(); Boolean measurable = true; Int32 options = 0; Int32 errors = 0; switch (modelType) { case swDocumentTypes_e.swDocASSEMBLY: fFormat = ".EASM"; break; case swDocumentTypes_e.swDocPART: fFormat = ".EPRT"; break; default: ExportPDFException e = new ExportPDFException("Document type error."); //e.Data.Add("who", System.Environment.UserName); //e.Data.Add("when", DateTime.Now); throw e; } swApp.ActivateDoc3(sourcePath, true, options, ref errors); swModel = (ModelDoc2)swApp.ActiveDoc; Configuration swConfig = (Configuration)swModel.GetActiveConfiguration(); swFrame.SetStatusBarText("Positioning model."); swModel.ShowNamedView2("*Dimetric", 9); swModel.ViewZoomtofit2(); if (!swApp.GetUserPreferenceToggle((int)swUserPreferenceToggle_e.swEDrawingsOkayToMeasure)) { swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swEDrawingsOkayToMeasure, true); measurable = false; } else { measurable = true; } EdrwTarget.Add(String.Format("{0}{1}\\{2}{3}", APathSet.KPath, altPath, sourceName, fFormat)); EdrwTarget.Add(String.Format("{0}{1}\\{2}{3}{4}", APathSet.GPath, altPath, sourceName, Rev, fFormat)); if (APathSet.ExportSTEP) { STEPTarget.Add(String.Format("{0}{1}\\{2}{3}", APathSet.KPath, altPath, sourceName, @".STEP")); STEPTarget.Add(String.Format("{0}{1}\\{2}{3}{4}", APathSet.GPath, altPath, sourceName, Rev, @".STEP")); } Boolean success = SaveSTEPorEDrw(EdrwTarget); if (STEPTarget.Count > 0) { success = SaveSTEPorEDrw(STEPTarget); } if (!measurable) { swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swEDrawingsOkayToMeasure, false); } if (!ml.Contains(swModel.GetPathName())) { swFrame.SetStatusBarText("Closing model."); swApp.CloseDoc(sourcePath); } else if (APathSet.SaveFirst) { swModel.SaveSilent(); } int err = 0; swApp.ActivateDoc3(currentDoc.GetTitle(), true, (int)swRebuildOnActivation_e.swDontRebuildActiveDoc, ref err); return(success); }
private bool GetCutComponents(ModelDoc2 swModel, out LinkedList<Component2> outCutComponents, out LinkedList<Component2> outShelfComponents, out bool delete) { delete = false; var swComponents = new LinkedList<Component2>(); ModelDoc2 swCompModel; outCutComponents = new LinkedList<Component2>(); outCutComponents.Clear(); outShelfComponents = new LinkedList<Component2>(); outShelfComponents.Clear(); var swConfig = (Configuration)swModel.GetActiveConfiguration(); if (swConfig != null) { var swRootComponent = (Component2)swConfig.GetRootComponent(); if (GetComponents(swRootComponent, swComponents, true, false)) { foreach (Component2 comp in swComponents) { swCompModel = (ModelDoc2)comp.GetModelDoc(); if (swCompModel != null) { if (swCompModel.get_CustomInfo2("", "swrfIsCut") == "Yes") { outCutComponents.AddLast(comp); } if (swCompModel.get_CustomInfo2("", "swrfIsShelf") == "Yes") { if (swCompModel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY) swCompModel.DeleteCustomInfo2("", "swrfIsShelf"); else { if (comp.GetTexture("") != null) swCompModel.Save(); outShelfComponents.AddLast(comp); } #region �������� ������ �������� ��������� var swFeat = comp.FirstFeature(); while (swFeat != null) { if (swFeat.GetTypeName2() == "Cavity") { if (swFeat.Name.Contains("#swrf")) { swFeat.Select(true); delete = true; } } swFeat = swFeat.IGetNextFeature(); } if (delete) { swModel.DeleteSelection(true); swModel.ClearSelection2(true); GC.Collect(); } #endregion } } } } } return true; }