private void TreeViewLinkPropertiesAfterSelect(object sender, TreeViewEventArgs e) { Font fontRegular = new Font(treeViewJointTree.Font, FontStyle.Regular); Font fontBold = new Font(treeViewJointTree.Font, FontStyle.Bold); if (previouslySelectedNode != null) { SaveLinkDataFromPropertyBoxes(previouslySelectedNode.Link); previouslySelectedNode.NodeFont = fontRegular; } LinkNode node = (LinkNode)e.Node; node.NodeFont = fontBold; node.Text = node.Text; ActiveSWModel.ClearSelection2(true); SelectionMgr manager = ActiveSWModel.SelectionManager; SelectData data = manager.CreateSelectData(); data.Mark = -1; foreach (Component2 component in node.Link.SWComponents) { component.Select4(true, data, false); } FillLinkPropertyBoxes(node.Link); treeViewLinkProperties.Focus(); previouslySelectedNode = node; }
public void InsertBom() { SldWorks swApp = default(SldWorks); ModelDoc2 swModel = default(ModelDoc2); SelectionMgr swSelMgr = default(SelectionMgr); FeatureManager swFeatMgr = default(FeatureManager); SolidWorks.Interop.sldworks.View swView; BomTableAnnotation swBomAnn = default(BomTableAnnotation); BomFeature swBomFeat = default(BomFeature); long anchorType = 0; long bomType = 0; string configuration = null; string tableTemplate = null; object visible = null; DrawingDoc swDraw; Sheet swSheet = default(Sheet); //swApp = DirectCast(Marshal.GetActiveObject("SldWorks.Application"), SldWorks) swApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application"); swModel = swApp.ActiveDoc; swFeatMgr = swModel.FeatureManager; swDraw = (DrawingDoc)swModel; swSheet = swDraw.GetCurrentSheet(); swModel.Extension.SetUserPreferenceString((int)swUserPreferenceStringValue_e.swDetailingLayer, (int)swUserPreferenceOption_e.swDetailingBillOfMaterial, ""); //ecли FALSE вставляются все конфигурации swModel.Extension.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, 0, false); swModel.Extension.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swBomTableDontAddQTYNextToConfigName, 0, true); swModel.Extension.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swDontCopyQTYColumnNameFromTemplate, 0, true); //swDraw.SetUserPreferenceIntegerValue(swBomTableZeroQuantityDisplay, swZeroQuantityBlank); //Select View swModel.ClearSelection2(true); swView = swDraw.GetCurrentSheet().GetViews()[0]; //Insert BOM Table anchorType = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft; bomType = (int)swBomType_e.swBomType_TopLevelOnly; swModel.ClearSelection2(true); configuration = ""; tableTemplate = "C:\\Program Files\\SW-Complex\\Template.sldbomtbt"; swBomAnn = swView.InsertBomTable2(false, -0, -0, (int)anchorType, (int)bomType, configuration, tableTemplate); swFeatMgr.UpdateFeatureTree(); swBomFeat = swBomAnn.BomFeature; var Names = swBomFeat.GetConfigurations(false, visible); visible = true; swBomFeat.SetConfigurations(true, visible, Names); }
public static void Set_transparency(ModelDoc2 swModel, string name) { AssemblyDoc swAssembly = null; Component2 swComp = null; ModelDoc2 swCompDoc = null; bool boolstatus = false; try { if (swModel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY) { swModel.ClearSelection2(true); // boolstatus = swModel.Extension.SelectByID2(name + "@" + docname, "COMPONENT", 0, 0, 0, true, 0, null, 0); // SelectionMgr SwSelMgr = swModel.SelectionManager; swAssembly = (AssemblyDoc)swModel; var Components = swAssembly.GetComponents(false); for (int i = 0; i < Components.Length; i++) { //swComp = swAssembly.GetComponentByName(name); swComp = Components[i]; if (swComp != null) { if (swComp.Name2.Contains(name)) { // MessageBox.Show(name); var vMatProps = swComp.MaterialPropertyValues; if (vMatProps == null) { swCompDoc = swComp.GetModelDoc(); if (swCompDoc == null) { return; } vMatProps = swCompDoc.MaterialPropertyValues; } vMatProps[7] = 1; //Transparency swComp.MaterialPropertyValues = vMatProps; swModel.ClearSelection2(true); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
public void AutoRenameBodies() { List <BodyModel> needRenameBodies = bodyModels.FindAll(x => x.comment != ""); ModelDoc2 swModel = null; swModel = (ModelDoc2)iswApp.ActiveDoc; PartDoc swPart = (PartDoc)swModel; for (int i = 0; i < needRenameBodies.Count; i++) { swModel.ClearSelection2(true); string actionbodyName = needRenameBodies[i].name.ToString(); Boolean boolstatus = swModel.Extension.SelectByID2(actionbodyName, "SOLIDBODY", 0, 0, 0, false, 0, null, 0); if (boolstatus == true) { var swSelectionManager = (SelectionMgr)swModel.SelectionManager; var b = (Feature)swSelectionManager.GetSelectedObject6(1, -1); int maxQ = bodyModels.FindAll(x => x.name.Contains(needRenameBodies[i].refBodyname) == true).Count; string tempbodyName = ""; // needRenameBodies[i].comment + (maxQ + 1).ToString(); Boolean haveThisName = true; // swModel.Extension.SelectByID2(tempbodyName, "SOLIDBODY", 0, 0, 0, false, 0, null, 0); if (haveThisName) { while (haveThisName == true) { maxQ = maxQ + 1; tempbodyName = needRenameBodies[i].comment + maxQ.ToString(); swModel.ClearSelection2(true); haveThisName = swModel.Extension.SelectByID2(tempbodyName, "SOLIDBODY", 0, 0, 0, false, 0, null, 0); } } b.Name = tempbodyName; swModel.EditRebuild3(); } } }
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 override void Bild(ModelDoc2 swModel) { swModel.ActivateSelectedFeature(); swModel.ClearSelection2(true); SmartTools.SelectFromList(swModel, Sselect); swModel.FeatureManager.FeatureCircularPattern4(Number, Spacing, FlipDirection, DName, GeometryPattern, EqualSpacing, VaryInstance); }
public override void Bild(ModelDoc2 swModel) { base.Bild(swModel); swModel.ClearSelection2(true); base.SelectByAll(); swModel.FeatureManager.FeatureCut3(Sd, Flip, Dir, T1, T2, D1, D2, Dchk1, Dchk2, Ddir1, Ddir2, Dang1, Dang2, OffsetReverse1, OffsetReverse2, TranslateSurface1, TranslateSurface2, NormalCut, UseFeatScope, UseAutoSelect, AssemblyFeatureScope, AutoSelectComponents, PropagateFeatureToParts, T0, StartOffset, FlipStartOffset); }
public static void RoundCorner(this ModelDoc2 @this, double d, SketchSegment segment1, SketchSegment segment2) { @this.ClearSelection2(true); segment1.Select(true); segment2.Select(true); @this.SketchManager.CreateFillet(d, 1); }
// Opens a Solidworks part, given a part TreeNode private bool OpenSketchFromNode(TreeNode sketchNode) { // Get custom SketchNodeInfo object from this node SketchNodeInfo sNodeInfo = (SketchNodeInfo)sketchNode.Tag; if (sNodeInfo == null) { ShowNonFatalError("Sketch node is missing SketchNodeInfo tag"); return(false); } // Get the sketch feature from SketchNodeInfo string sketchName = sNodeInfo.SketchName; if (sketchName == null) { ShowNonFatalError("SketchNodeInfo is missing a Sketch Feature variable"); return(false); } // Opens the part from sketch's parent node (if not already open) if (!OpenPartFromNode(sketchNode.Parent)) { ShowNonFatalError("Failed to open part from sketch node's parent node"); return(false); } // Clear all previous selections in part currentModel.ClearSelection2(true); // Open "Edit Sketch" and make sketch Normal-To (ctrl+8 shortcut) OpenSketchNormalToByName(sketchName); return(false); }
public void writeSolidWorksDocumentAsSTL(string path) { ModelDoc2 swModelDoc = swApp.ActiveDoc; swModelDoc.ClearSelection2(true); swModelDoc.SaveAs3(path + ".stl", 0, 0); }
// (UNUSED, for future reference) Loops through all sketches in a given ModelDoc2 model public void iterate_each_sketch_in_model(ModelDoc2 thisModel) { Console.WriteLine("Iterating through all sketches in this model..."); if (thisModel == null) { Console.WriteLine("** Error: thisModel is NULL! Something's wrong..."); } Feature currentFeature = default(Feature); int numParentFeatures = 0; int numSketches = 0; currentFeature = thisModel.IFirstFeature(); List <Feature> listOfSketches = new List <Feature>(); // Loop through all features in 'thisModel' while (currentFeature != null) { numParentFeatures++; if (currentFeature.GetTypeName2() == "ProfileFeature") // If child is type Sketch { // Gather properties of sketch Console.WriteLine("Iterating through parentFeature" + numParentFeatures + " ('" + currentFeature.Name + "') in this model..."); GetConstrainedStatus(currentFeature); // Clear all previous selections thisModel.ClearSelection2(true); // Select the current sketch (we verified this feature is a sketch) if (currentFeature.Select2(false, 0)) { Console.WriteLine("Successfully selected Sketch ('" + currentFeature.Name + "')"); listOfSketches.Add(currentFeature); } else { Console.WriteLine(" ** ERROR: Failed to select Sketch ('" + currentFeature.Name + "')"); break; } // Edit the (previously selected) sketch Console.WriteLine(" Editing sketch......"); thisModel.EditSketchOrSingleSketchFeature(); // Run the 'Normal-To' view command RunNormalToSketchCommand(); // Exit out of "Edit Sketch" and rebuild thisModel.InsertSketch2(true); } currentFeature = currentFeature.GetNextFeature(); if (currentFeature == null) { Console.WriteLine("Failed to get next feature! (GetNextFeature() is NULL)"); } } Console.WriteLine("Got " + numSketches + " sketches from this model"); }
public override void Bild(ModelDoc2 swModel) { base.Bild(swModel); swModel.ClearSelection2(true); if (Sselect == null || Sselect.Count == 0) { base.SelectByAll(); } else { SmartTools.SelectFromList(swModel, Sselect); } swModel.FeatureManager.FeatureRevolve2(SingleDir, IsSolid, IsThin, IsCut, ReverseDir, BothDirectionUpToSameEntity, Dir1Type, Dir2Type, Dir1Angle, Dir2Angle, OffsetReverse1, OffsetReverse2, OffsetDistance1, OffsetDistance2, ThinType, ThinThickness1, ThinThickness2, Merge, UseFeatScope, UseAutoSelect); }
// Set Materials public void ApplyMaterial(string partPath, string confName, int materialID, SldWorks swapp) { _swmodel = swapp.ActiveDoc; swapp.SetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swFileLocationsMaterialDatabases, GlobalPaths.PathToSwComplexFolder); // задаем базы данных материалов _swPartDoc = ((PartDoc)(_swmodel)); const string dbMatName = "vents-materials.sldmat"; ToSQL addMatXml = new ToSQL(); if (_swmodel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY) { Component2 comp = _swmodel.ISelectionManager.GetSelectedObject3(1); PartDoc swPartAssem = comp.GetModelDoc(); //// удаляем материал //swPartAssem.SetMaterialPropertyName("", ""); // применяем материал swPartAssem.SetMaterialPropertyName2(confName, dbMatName, addMatXml.AddMaterialtoXml(materialID)); _swmodel.ClearSelection2(true); } else if (_swmodel.GetType() == (int)swDocumentTypes_e.swDocPART) { // Если имя не пустое if (partPath != "") { //// удаляем материал //swPartDoc.SetMaterialPropertyName("", ""); // применяем материал _swPartDoc.SetMaterialPropertyName2(confName, dbMatName, addMatXml.AddMaterialtoXml(materialID)); //_swmodel.ForceRebuild3(false); //_swmodel.Save3((int)swSaveAsOptions_e.swSaveAsOptions_Silent, 0, 0); //swapp.CloseDoc(partPath); //swapp.ExitApp(); //swapp = null; } else { //// удаляем материал //swPartDoc.SetMaterialPropertyName(confName, ""); // применяем материал _swPartDoc.SetMaterialPropertyName2(confName, dbMatName, addMatXml.AddMaterialtoXml(materialID)); } } //catch (Exception ex) //{ // //swapp.SendMsgToUser(ex.ToString()); // MessageBox.Show(ex.Message); // Error = ex.ToString(); //} }
public static void SelectFromList(ModelDoc2 swModel, BindingList <String> Sselect) { swModel.ClearSelection2(true); foreach (String str in Sselect) { SmartTools.SelectByID(swModel, str); } }
public override void Bild(ModelDoc2 swModel) { base.Bild(swModel); swModel.ClearSelection2(true); base.SelectByAll(); swModel.FeatureManager.FeatureExtrusion2(Sd, Flip, Dir, T1, T2, D1, D2, Dchk1, Dchk2, Ddir1, Ddir2, Dang1, Dang2, OffsetReverse1, OffsetReverse2, TranslateSurface1, TranslateSurface2, Merge, UseFeatScope, UseAutoSelect, T0, StartOffset, FlipStartOffset); }
private static void drawRayForCamera(MathVector cameraDirection, IMathPoint centreOfVision, ModelDoc2 swDoc, SelectionMgr swSelectionMgr) { swDoc.ClearSelection2(true); Camera.removeRayIfPresent(swDoc); double[] cameraDirData = (double[])cameraDirection.ArrayData; double[] cameraOriginData = (double[])centreOfVision.ArrayData; swDoc.Insert3DSketch2(true); swDoc.SketchManager.AddToDB = true; swDoc.CreateLine2(cameraOriginData[0], cameraOriginData[1], cameraOriginData[2], cameraOriginData[0] + cameraDirData[0], cameraOriginData[1] + cameraDirData[1], cameraOriginData[2] + cameraDirData[2]); swDoc.Insert3DSketch2(true); swDoc.SketchManager.AddToDB = false; Feature sketch = swSelectionMgr.GetSelectedObject6(1, 0); sketch.Name = CAMERA_RAY_NAME; swDoc.ClearSelection2(true); }
public static void SelectSegments(this ModelDoc2 @this, IEnumerable <SketchSegment> segments) { @this.ClearSelection2(true); foreach (var segment in segments) { segment.Select(true); } }
public void Main() { ModelDoc2 swDoc = null; PartDoc swPart = null; DrawingDoc swDrawing = null; AssemblyDoc swAssembly = null; bool boolstatus = false; int longstatus = 0; int longwarnings = 0; // // New Document double swSheetWidth; swSheetWidth = 0; double swSheetHeight; swSheetHeight = 0; swDoc = ((ModelDoc2)(swApp.NewDocument("D:\\Program Files\\SolidWorks Corp\\SOLIDWORKS (2)\\lang\\chinese\\Tutorial\\part.prtdot" + "", 0, swSheetWidth, swSheetHeight))); swPart = swDoc; swApp.ActivateDoc2("Part1", false, ref longstatus); swDoc = ((ModelDoc2)(swApp.ActiveDoc)); ModelView myModelView = null; myModelView = ((ModelView)(swDoc.ActiveView)); myModelView.FrameState = ((int)(swWindowState_e.swWindowMaximized)); swDoc.SketchManager.InsertSketch(true); boolstatus = swDoc.Extension.SelectByID2("Front", "PLANE", -0.068230578696965388, 0.046649779711848, 0.0043111746054159822, false, 0, null, 0); swDoc.ClearSelection2(true); boolstatus = swDoc.Extension.SetUserPreferenceToggle(((int)(swUserPreferenceToggle_e.swSketchAddConstToRectEntity)), ((int)(swUserPreferenceOption_e.swDetailingNoOptionSpecified)), false); boolstatus = swDoc.Extension.SetUserPreferenceToggle(((int)(swUserPreferenceToggle_e.swSketchAddConstLineDiagonalType)), ((int)(swUserPreferenceOption_e.swDetailingNoOptionSpecified)), true); Array vSkLines = null; vSkLines = ((Array)(swDoc.SketchManager.CreateCornerRectangle(-0.05212005640233669, 0.022239709930839985, 0, 0.043660780232323892, -0.038612502517961472, 0))); swDoc.ClearSelection2(true); swDoc.SketchManager.InsertSketch(true); // // Named View swDoc.ShowNamedView2("*Trimetric", 8); swDoc.ViewZoomtofit2(); Feature myFeature = null; myFeature = ((Feature)(swDoc.FeatureManager.FeatureExtrusion2(true, false, false, 0, 0, 0.025, 0.01, false, false, false, false, 0.017453292519943334, 0.017453292519943334, false, false, false, false, true, true, true, 0, 0, false))); swDoc.ISelectionManager.EnableContourSelection = false; }
public static void DimensionWith(this SketchLine l1, SketchLine l2, double value, string linkName, SldWorks swApp) { ModelDoc2 swDoc = (ModelDoc2)swApp.ActiveDoc; bool bl = false; swDoc.ClearSelection2(true); bl = ((SketchSegment)l1).Select(false); bl = ((SketchSegment)l2).Select(true); Point textPoint = new Point((l1.toLine().Start.X + l2.toLine().Start.X) / 2, (l1.toLine().Start.Y + l2.toLine().Start.Y) / 2, (l1.toLine().Start.Z + l2.toLine().Start.Z) / 2); swDoc.AddDimension2(textPoint.X, textPoint.Y, 0); swDoc.ClearSelection2(true); }
public void CreatePart() { string guild = Guid.NewGuid().ToString(); string root = @"C:\Users\timos\source\Project\Solution\Project\VenturiPart\" + guild; if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } else { throw new ArgumentException("Чертеж уже существует."); } swApp = GetSolidWorks.GetApplication(); defaultPartTemplate = swApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart); swApp.NewDocument(defaultPartTemplate, 0, 0, 0); swModel = (ModelDoc2)swApp.ActiveDoc; swModel.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, false, 0, null, 0); swModel.SketchManager.InsertSketch(true); swModel.ClearSelection2(true); swModel.SketchManager.CreateCenterLine(0.000000, 0.000000, 0.000000, -0.173611, 0.000000, 0.000000); swModel.SketchManager.CreateLine(0.000000, -0.026016, 0.000000, -0.039342, -0.026016, 0.000000); swModel.SketchManager.CreateLine(-0.039342, -0.026016, 0.000000, -0.075130, -0.007488, 0.000000); swModel.SketchManager.CreateLine(-0.075130, -0.007488, 0.000000, -0.092897, -0.007488, 0.000000); swModel.SketchManager.CreateLine(-0.092897, -0.007488, 0.000000, -0.173611, -0.026016, 0.000000); swModel.ClearSelection2(true); swModel.Extension.SelectByID2("Point8", "SKETCHPOINT", -0.17361079172679997, -0.026016237064323086, 0, false, 0, null, 0); swModel.Extension.SelectByID2("Point2", "SKETCHPOINT", -0.17361079172679997, 0, 0, true, 0, null, 0); swModel.SketchAddConstraints("sgVERTICALPOINTS2D"); swModel.Extension.SelectByID2("Point4", "SKETCHPOINT", 0, -0.026016237064323086, 0, false, 0, null, 0); swModel.Extension.SelectByID2("Point1", "SKETCHPOINT", 0, 0, 0, true, 0, null, 0); swModel.SketchAddConstraints("sgVERTICALPOINTS2D"); swModel.Extension.SelectByID2("Point4", "SKETCHPOINT", 0, -0.026016237064323086, 0, false, 0, null, 0); swModel.Extension.SelectByID2("Point1", "SKETCHPOINT", 0, 0, 0, true, 0, null, 0); swModel.ClearSelection2(true); swModel.FeatureManager.FeatureRevolve2(true, true, true, false, false, false, 0, 0, 6.2831853071796004, 0, false, false, 0.01, 0.01, 0, 0.005, 0.01, true, true, true); swModel.ISelectionManager.EnableContourSelection = false; swModel.ViewZoomtofit2(); swModel.ForceRebuild3(true); swModel.SaveAs(PartName + ".SPLDRT"); swApp = null; }
//装配体中插入新零件 public void InsretComponent() { string[] strCompName = new string[3]; string[] firstSelect = new string[15]; string[] secondSelect = new string[15]; swModel = (ModelDoc2)swApp.OpenDoc6("G:\\CodeTest\\planetAssembly.SLDASM", (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); swAssembly = (AssemblyDoc)swModel; ////// string assemblyTitle = swModel.GetTitle(); //获取装配体名称 string[] strings = assemblyTitle.Split(new Char[] { '.' }); //使用分隔符分割装配体实例号 assemblyName = (string)strings[0]; //获得装配体名称 //打开零件并添加零件到装配体 swModel = (ModelDoc2)swApp.OpenDoc6("G:\\CodeTest\\内齿轮.SLDPRT", (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); //swComponent = (IComponent2)swAssembly.AddComponent5("内齿轮.sldprt", (int)swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, "", false, "", 0, 0, 0); //strCompName[0] = swComponent.Name2; //获取内齿轮名称 //swApp.DocumentVisible(false, (int)swDocumentTypes_e.swDocPART); //swModel = (ModelDoc2)swApp.OpenDoc6("G:\\CodeTest\\行星轮.SLDPRT", (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); //swComponent = (IComponent2)swAssembly.AddComponent5("行星轮.sldprt", (int)swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, "", false, "", 0, -0.0456, 0); //strCompName[1] = swComponent.Name2; //获取行星轮名称 //swApp.DocumentVisible(false, (int)swDocumentTypes_e.swDocPART); //swModel = (ModelDoc2)swApp.OpenDoc6("G:\\CodeTest\\输入轴.SLDPRT", (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings); //swComponent = (IComponent2)swAssembly.AddComponent5("输入轴.sldprt", (int)swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, "", false, "", 0, 0, 0); //strCompName[2] = swComponent.Name2; //获取输入轴名称 //swApp.DocumentVisible(false, (int)swDocumentTypes_e.swDocPART); //添加同心配合关系 firstSelect[0] = "前视基准面@" + strCompName[0] + "@" + assemblyName; //第一个选择选项 secondSelect[0] = "前视基准面@" + strCompName[2] + "@" + assemblyName; //第二个选择选项 swModel.ClearSelection2(true); swModelEx = swModel.Extension; swModelEx.SelectByID2(firstSelect[0], "PLANE", 0, 0, 0, false, 1, null, 0);//????????? swModelEx.SelectByID2("前视基准面@输入轴-1@planetAssembly", "PLANE", 0, 0, 0, true, 0, null, 0); swAssembly.AddMate3((int)swMateType_e.swMateCOINCIDENT, (int)swMateAlign_e.swMateAlignALIGNED, false, 0, 0, 0, 0, 0, 0, 0, 0, false, out mateError); swModel.ClearSelection2(true); //添加距离约束 swModelEx.SelectByID2("Point1@原点@行星轮-1@装配体5", "EXTSKETCHPOINT", 0, 0, 0, true, 1, null, 0); swModelEx.SelectByID2("Point1@原点@输入轴-1@装配体5", "EXTSKETCHPOINT", 0, 0, 0, true, 1, null, 0); swAssembly.AddMate3((int)swMateType_e.swMateDISTANCE, (int)swMateAlign_e.swMateAlignALIGNED, false, 0.0455, 0.0455, 0.0455, 0, 0, 0, 0, 0, false, out mateError); //添加齿轮配合 }
bool IsSuppressedEdgeFlange(string featureName) { modelDoc.Extension.SelectByID2(featureName, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); var swSelMgr = (SelectionMgr)modelDoc.SelectionManager; var swFeat = (Feature)swSelMgr.GetSelectedObject6(1, -1); bool[] states = swFeat.IsSuppressed2(2, modelDoc.GetConfigurationNames()); bool stat = states[0]; modelDoc.ClearSelection2(true); return(stat); }
// Строит или изменяет модель public void Build() { InitAndRunSwApp(); // имена размеров в документе полумуфты string fingerParameter1 = "fingers@Круговой массив1"; string fingerParameter2 = "fingers@Круговой массив2"; string nomianalDiameterParameter = "nominalDiameter@Эскиз1"; // имя полумуфты в сборке (имя компонента верхнего уровня) string assemblyPolumuftaName = "Полумуфта-1"; // Менеджер выделения, выбора SelectionMgr swSelMgr = (SelectionMgr)swModel.SelectionManager; // удалить выделение swModel.ClearSelection2(true); Component2 swComp = assembly.GetComponentByName(assemblyPolumuftaName); // выбрать полумуфту, не добавлять к выбранным, дата?, показать всплывающее кокшко swComp.Select4(false, null, false); int info = 0; // начать изменение полумуфты assembly.EditPart2(false, false, ref info); // получить редактируемую модель ModelDoc2 polumufta = (ModelDoc2)assembly.GetEditTarget(); // установка изменяемых параметров для всех конфигураций polumufta.Parameter(fingerParameter1).SetSystemValue3( countFingers, (int)swSetValueInConfiguration_e.swSetValue_InAllConfigurations ); polumufta.Parameter(fingerParameter2).SetSystemValue3( countFingers, (int)swSetValueInConfiguration_e.swSetValue_InAllConfigurations ); polumufta.Parameter(nomianalDiameterParameter).SetSystemValue3( nominalDiameter, (int)swSetValueInConfiguration_e.swSetValue_InAllConfigurations ); // ?? bool retVal = polumufta.EditSuppress2(); //Debug.Assert(retVal); // ?? assembly.EditAssembly(); swModel.EditRebuild3(); swModel.ForceRebuild3(false); swModel.ViewZoomtofit2(); }
public void makeBindings(ModelDoc2 swModel) { foreach (string[] list in pack) { swModel.ClearSelection2(true); for (int i = 1; i < list.Length; i++) { SmartTools.SelectByID(swModel, list[i]); } swModel.SketchAddConstraints(list[0]); } }
public void makeDimensions(ModelDoc2 swModel) { foreach (string[] list in pack) { swModel.ClearSelection2(true); for (int i = 6; i < list.Length; i++) { SmartTools.SelectByID(swModel, list[i]); } swModel.AddDimension2(Convert.ToDouble(list[3]), Convert.ToDouble(list[4]), Convert.ToDouble(list[5])); } }
//Selects components from a list. public static void selectComponents(ModelDoc2 model, List<Component2> components, bool clearSelection = true, int mark = -1) { if (clearSelection) { model.ClearSelection2(true); } SelectionMgr manager = model.SelectionManager; SelectData data = manager.CreateSelectData(); data.Mark = mark; foreach (Component2 component in components) { component.Select4(true, data, false); } }
public void CreteShaft() { if (CheckSWConnect() == false) { return; } CreateBase(); foreach (var stage in Stages) { if (stage.GetType() == typeof(CircularStage)) { CircularStage CurrentStage = stage as CircularStage; if (CurrentStage.StageFeature != null) { CurrentStage.StageFeature.AddFeature(SwApp, SwModel, CurrentStage.P1, CurrentStage.P2); } } } SwModel.Rebuild(3); SwModel.ClearSelection2(true); }
private void Contraindre(Feature plan, Face2 e) { AssemblyDoc Ass = MdlBase.eAssemblyDoc(); e.eSelectEntite(MdlBase); plan.eSelect(true); int longstatus = 0; Ass.AddMate5((int)swMateType_e.swMateCOINCIDENT, (int)swMateAlign_e.swMateAlignCLOSEST, false, 0, 0, 0, 0, 0, 0, 0, 0, false, false, 0, out longstatus); MdlBase.ClearSelection2(true); }
public static void CreatePlane(ModelDoc2 FeatDoc) { SketchManager SwSketchMrg = FeatDoc.SketchManager;//获得SketchManager对象 FeatDoc.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, false, 0, null, 0); SwSketchMrg.InsertSketch(true); //进入编辑草图模式 SwSketchMrg.CreateLine(0, 0, 0, 0.01, 0.01, 0); SwSketchMrg.InsertSketch(true); //退出编辑草图模式 FeatDoc.ClearSelection2(true); FeatureManager SwFeatMrg = FeatDoc.FeatureManager; FeatDoc.Extension.SelectByID2("Point2@草图1", "EXTSKETCHPOINT", 0, 0, 0, false, 0, null, 0); FeatDoc.Extension.SelectByID2("Line1@草图1", "EXTSKETCHSEGMENT", 0, 0, 0, true, 1, null, 0); SwFeatMrg.InsertRefPlane(4, 0, 2, 0, 0, 0); }
//Selects components from a list. public static void selectComponents(ModelDoc2 model, List <Component2> components, bool clearSelection = true, int mark = -1) { if (clearSelection) { model.ClearSelection2(true); } SelectionMgr manager = model.SelectionManager; SelectData data = manager.CreateSelectData(); data.Mark = mark; foreach (Component2 component in components) { component.Select4(true, data, false); } }
//Converts the SW component references to PIDs public static void SaveSWComponents(ModelDoc2 model, Link Link) { model.ClearSelection2(true); byte[] PID = SaveSWComponent(model, Link.SWMainComponent); if (PID != null) { Link.SWMainComponentPID = PID; } Link.SWComponentPIDs = SaveSWComponents(model, Link.SWComponents); foreach (Link Child in Link.Children) { SaveSWComponents(model, Child); } }
//Selects the components of a link. Helps highlight when the associated node is selected from the tree public static void selectComponents(ModelDoc2 model, link Link, bool clearSelection, int mark = -1) { if (clearSelection) { model.ClearSelection2(true); } SelectionMgr manager = model.SelectionManager; SelectData data = manager.CreateSelectData(); data.Mark = mark; if (Link.SWComponent != null) { Link.SWComponent.Select4(true, data, false); } else { selectComponents(model, Link.SWcomponents, false); } foreach (link child in Link.Children) { selectComponents(model, child, false, mark); } }
//Converts the SW component references to PIDs public static void saveSWComponents(ModelDoc2 model, link Link) { model.ClearSelection2(true); byte[] PID = saveSWComponent(model, Link.SWMainComponent); if (PID != null) { Link.SWMainComponentPID = PID; } Link.SWComponentPIDs = saveSWComponents(model, Link.SWcomponents); foreach (link Child in Link.Children) { saveSWComponents(model, Child); } }
private void AutoDimensionDrawing2(ModelDoc2 swModel, bool many ) { bool del3List = false; var thrdList = new List<string>(); int shi = 0; isValidXml = true; var swDrawing = (DrawingDoc)swModel; if (swModel.GetCustomInfoValue("", "AutoDim") == "No") { if (many) { MessageBox.Show(@"Если хотите образмерить чертеж, смените No на Yes в поле 'AutoDim' свойств данного чертежа", @"MrDoors", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } isValidXml = false; } if (swModel.GetCustomInfoValue("", "MakeCNCprog") == "Yes") { _createProgramm = true; } if (!isValidXml && !_createProgramm) // если не надо создавать программу и авто дим = но, то образмеривать просто не нужно. return; swModel.Extension.SetUserPreferenceDouble((int)swUserPreferenceDoubleValue_e.swDetailingDimToDimOffset, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 0.006); swModel.Extension.SetUserPreferenceDouble((int)swUserPreferenceDoubleValue_e.swDetailingObjectToDimOffset, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 0.010); Dictionary<string, bool> listSide; string targetModelPath = null; if (!File.Exists(Path.Combine(Path.GetDirectoryName(_swAdd.RootModel.GetPathName()), "fpTime.txt"))) { //MessageBox.Show("Образмеривание детали может пройти некорректно! Для корректного образмеривания детали необходимо произвести Окончательную обработку заказа."); throw new Exception("Образмеривание детали может пройти некорректно! Для корректного образмеривания детали необходимо произвести Окончательную обработку заказа."); } else { //просто взять Sketch Number string fnameWithoutExt = Path.GetFileNameWithoutExtension(swModel.GetPathName()); fnameWithoutExt = fnameWithoutExt.Substring(fnameWithoutExt.Length - 4, 4); SwDMDocument8 swDoc = null; SwDMApplication swDocMgr = SwAddin.GetSwDmApp(); SwDmDocumentOpenError oe; SwDmCustomInfoType type; if (!(fnameWithoutExt[0] == '#' && (fnameWithoutExt[3] == 'P' || fnameWithoutExt[3] == 'p'))) { swDoc = (SwDMDocument8) swDocMgr.GetDocument(Path.ChangeExtension(swModel.GetPathName(), "SLDASM"),SwDmDocumentType.swDmDocumentAssembly, true, out oe); } else { object brokenRefVar; SwDMSearchOption src = swDocMgr.GetSearchOptionObject(); var swDocDraw = (SwDMDocument8)swDocMgr.GetDocument(swModel.GetPathName(), SwDmDocumentType.swDmDocumentDrawing, true, out oe); var varRef = (object[])swDocDraw.GetAllExternalReferences2(src, out brokenRefVar); swDocDraw.CloseDoc(); targetModelPath = (string)varRef[0]; swDoc = (SwDMDocument8)swDocMgr.GetDocument(targetModelPath, SwDmDocumentType.swDmDocumentAssembly, true, out oe); } if (swDoc != null) { var prop = swDoc.GetCustomProperty("Sketch Number", out type); if (string.IsNullOrEmpty(prop) || prop == "0") throw new Exception("Образмеривание детали прервано, т.к. может пройти некорректно ! Для корректного образмеривания детали необходимо произвести Окончательную обработку заказа."); swDoc.CloseDoc(); } _swAdd.SetModelProperty(swModel, "WasMesure", string.Empty, swCustomInfoType_e.swCustomInfoYesOrNo, "Yes", true); } string pathXml = WriteXmlFile(swModel, isValidXml, targetModelPath); bool isNeededSheetNumber = PrepareDrawingDoc(swModel, out listSide); bool dimOnlyNew = false; if (swModel.GetCustomInfoValue("", "DimOnlyNew") == "Yes") dimOnlyNew = true; var vSheetNames = (string[])swDrawing.GetSheetNames(); var rootNode = _node; bool atLeastOneF1View = false; foreach (var vSheetName in vSheetNames) { bool iftherewasAhole = false; XmlElement element = null; XmlElement sheetNode = null; KeyValuePair<string,string> tableNameAttribute = new KeyValuePair<string, string>(); if (_createProgramm && !string.IsNullOrEmpty(pathXml)) { element = _cxml.CreateElement("Sheet"); element.SetAttribute("Name", vSheetName); _node = rootNode.AppendChild(element); sheetNode = element; } double vScale = 0; var type = new List<string>(); var listSize = new List<SizeForDim>(); swDrawing.ActivateSheet(vSheetName); swModel.Extension.SelectByID2(vSheetName, "SHEET", 0, 0, 0, true, (int)swSelectionMarkAction_e.swSelectionMarkAppend, null, 0); swModel.ViewZoomToSelection(); swModel.ClearSelection(); var swSheet = (Sheet)swDrawing.GetCurrentSheet(); var swViews = (object[])swSheet.GetViews(); bool side = shi == 1; if (isNeededSheetNumber && listSide.ContainsKey(vSheetName.Substring(vSheetName.Length - 1))) side = listSide[vSheetName.Substring(vSheetName.Length - 1)]; if (vSheetName.ToUpper().Contains("FACE")) side = true; if (vSheetName.ToUpper().Contains("BACK")) side = false; if (swViews != null) { var rootViewElement = _node; if (Properties.Settings.Default.ViewsBeforeDimen) ReplaceViews(swViews, swDrawing); foreach (var t in swViews) { #region Образмеривание вида var swView = (View) t; swModel.ClearSelection2(true); const string expr = "^F[1-6]$"; Match isMatch = Regex.Match(swView.Name, expr, RegexOptions.IgnoreCase); if (_createProgramm && swView.Name.ToLower().Contains("const")) { //Logging.Log.Instance.Fatal(@"На данный чертеж программа не будет создана! " + swModel.GetPathName() + "swView.Name = " + swView.Name); //MessageBox.Show(@"На данный чертеж программа не будет создана!", @"MrDoors",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); } if (!(isMatch.Success || swView.Name.Contains("Чертежный вид")) || swView.Name.ToLower().Contains("const") || swView.Type == (int)swDrawingViewTypes_e.swDrawingDetailView) continue; if (_createProgramm && !isMatch.Success) { _createProgramm = false; //Logging.Log.Instance.Fatal(@"На данный чертеж программа не будет создана! " + swModel.GetPathName() + "swView.Name = " + swView.Name); //MessageBox.Show(@"На данный чертеж программа не будет создана!", @"MrDoors", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } swDrawing.ActivateView(swView.GetName2()); swView.UseSheetScale = 0; var list = HideUnusedComponents(swView, dimOnlyNew); try { vScale = ((double[]) swView.ScaleRatio)[1]; swView.SetDisplayMode3(false, (int) swDisplayMode_e.swFACETED_HIDDEN, true, true); #region Процесс образмеривания using (var d = new DimensionView(_swApp, BlockPositionExtension.FromBool(side), dimOnlyNew)) { d.DimView(side); if (!iftherewasAhole) iftherewasAhole = d.IsHole; if (!isNeededSheetNumber && !side && !iftherewasAhole) del3List = true; else { if (isNeededSheetNumber && !iftherewasAhole) { del3List = true; thrdList.Add(vSheetName); } } foreach (var tp in d.List) { if (!type.Contains(tp)) type.Add(tp); } listSize.Add(d.AddSize); #region Запись данных в xml файл if (element != null) { element = _cxml.CreateElement("View"); element.SetAttribute("Name", swView.Name); if (swView.Name == "F1") { atLeastOneF1View = true; SwDmDocumentOpenError oe; SwDMApplication swDocMgr = SwAddin.GetSwDmApp(); var swDoc = (SwDMDocument8)swDocMgr.GetDocument(Path.ChangeExtension(swModel.GetPathName(), "SLDASM"), SwDmDocumentType.swDmDocumentAssembly, true, out oe); if (swDoc != null) { var cit = new SwDmCustomInfoType(); string[] names = swDoc.GetCustomPropertyNames(); string extFeats = null,faner11 = null,faner12 = null,faner21 = null,faner22 = null; if (names.Contains("ExtFanerFeats")) extFeats = swDoc.GetCustomProperty("ExtFanerFeats", out cit); double angle = 57.29577951308232*swView.Angle; //(180/П) if (Math.Abs(angle) < 0.000001 || Math.Abs(angle + 90) < 0.000001 || Math.Abs(angle - 270) < 0.000001 || Math.Abs(angle - 180) < 0.000001 || Math.Abs(angle - 90) < 0.000001) //!string.IsNullOrEmpty(extFeats) && extFeats == "Yes" && { if (names.Contains("Faner11")) faner11 = swDoc.GetCustomProperty("Faner11", out cit); if (names.Contains("Faner12")) faner12 = swDoc.GetCustomProperty("Faner12", out cit); if (names.Contains("Faner21")) faner21 = swDoc.GetCustomProperty("Faner21", out cit); if (names.Contains("Faner22")) faner22 = swDoc.GetCustomProperty("Faner22", out cit); var tmpElem = _cxml.CreateElement("Comment"); string comment = FrmEdge.GetCommentFromProperties(faner11,faner12,faner21,faner22, angle, _swAdd,swModel); double angle2 = angle + 90; double angle4 = angle + 180; double angle3 = angle + 270; if (angle2 > 270) angle2 = angle2%360; if (angle3 > 270) angle3 = angle3 % 360; if (angle4 > 270) angle4 = angle4 % 360; string comment2 = FrmEdge.GetCommentFromProperties(faner11, faner12, faner21, faner22, angle2, _swAdd, swModel); string comment3 = FrmEdge.GetCommentFromProperties(faner11, faner12, faner21, faner22, angle3, _swAdd, swModel); string comment4 = FrmEdge.GetCommentFromProperties(faner11, faner12, faner21, faner22, angle4, _swAdd, swModel); tmpElem.SetAttribute("Rot270",comment3); tmpElem.SetAttribute("Rot180",comment4); tmpElem.SetAttribute("Rot90", comment2); tmpElem.SetAttribute("Rot0", comment); rootNode.PrependChild(tmpElem); } } //swDoc.CloseDoc(); //int warnings = 0; //int errors = 0; //var swModelDoc = _swApp.OpenDoc6(Path.ChangeExtension(swModel.GetPathName(), "SLDASM"), (int)swDocumentTypes_e.swDocASSEMBLY, // (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, // warnings); //if (!string.IsNullOrEmpty(swModelDoc.CustomInfo2["", "ExtFanerFeats"]) && swModelDoc.CustomInfo2["", "ExtFanerFeats"] == "Yes") //{ // var tmpElem = _cxml.CreateElement("Comment"); // string comment = FrmEdge.GetComment(swModelDoc, swView.Angle, _swAdd); // tmpElem.SetAttribute("Rot270", string.Empty); // tmpElem.SetAttribute("Rot90", string.Empty); // tmpElem.SetAttribute("Rot0", comment); // rootNode.PrependChild(tmpElem); //} } if (_node != null) { _node = rootViewElement.AppendChild(element); switch (d.Side) { case BlockPosition.LeftTopToRightBottom: if (swView.Name == "F1") tableNameAttribute = new KeyValuePair<string, string>("F1","J"); if (swView.Name == "F6") { if (tableNameAttribute.Key!="F1") // F1 - приоритетнее tableNameAttribute = new KeyValuePair<string, string>("F6", "B"); } if (string.IsNullOrEmpty(tableNameAttribute.Key)) { tableNameAttribute = new KeyValuePair<string, string>("none","J"); } break; case BlockPosition.RightTopToLeftBottom: if (swView.Name == "F1") tableNameAttribute = new KeyValuePair<string, string>("F1","B"); if (swView.Name == "F6") { if (tableNameAttribute.Key!="F1") // F1 - приоритетнее tableNameAttribute = new KeyValuePair<string, string>("F6", "J"); } if (string.IsNullOrEmpty(tableNameAttribute.Key)) { tableNameAttribute = new KeyValuePair<string, string>("none", "B"); } break; case BlockPosition.LeftBottomToRightTop: case BlockPosition.RigthBottomToLeftTop: //MessageBox.Show( // "В этом чертеже начало координат находится внизу. Программа может быть создана некорректно!", // @"MrDoors", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // element = _cxml.CreateElement("Table"); // element.SetAttribute("Name", "Не удалось определить наименование стола!"); //_node=_node.AppendChild(element); break; } } int i = 0; string id = "id" + i; element = _cxml.CreateElement(id); element.SetAttribute("X", Math.Round(d.X).ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); element.SetAttribute("Y", Math.Round(d.Y).ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); if (swView.Name == "F1" || swView.Name == "F6") element.SetAttribute("Z", _z.ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); if (_node != null) _node.AppendChild(element); foreach (var ls in d.ListSize) { i++; id = "id" + i; element = _cxml.CreateElement(id); element.SetAttribute("X", ls.X.ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); element.SetAttribute("Y", ls.Y.ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); element.SetAttribute("Diameter", ls.Diameter.ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); element.SetAttribute("Depth",ls.Depth.ToString(CultureInfo.CreateSpecificCulture("ru-RU"))); if (_node != null) _node.AppendChild(element); } _node = _node.ParentNode; } #endregion } #endregion swView.SetDisplayMode3(false, (int) swDisplayMode_e.swFACETED_HIDDEN_GREYED, true, true); swDrawing.ActivateSheet(vSheetName); } catch (Exception e) { MessageBox.Show(@"Ошибка при образмеривании! " + e.Message, @"MrDoors", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (dimOnlyNew) ShowHiddenComponents(list); } #endregion } } if (type.Count != 0) LegendMaker(swModel, swDrawing, type, vScale); if (!string.IsNullOrEmpty(tableNameAttribute.Value)) sheetNode.SetAttribute("TableName", tableNameAttribute.Value); if (Properties.Settings.Default.ScaleWhenDimen && !del3List && shi != 0) AutoScaleSheet(listSize, swSheet, vScale, side); shi++; if(_node!=null) _node = _node.ParentNode; AutoArrangeDimentions(vSheetName,dimOnlyNew); } swModel.EditRebuild3(); if (shi == 3) { if (del3List) { if (isNeededSheetNumber && thrdList.Count > 0) foreach (var sh in thrdList) swModel.Extension.SelectByID2(sh, "SHEET", 0, 0, 0, true, 0, null, 0); else { if (!swModel.Extension.SelectByID2("Лист3", "SHEET", 0, 0, 0, false, 0, null, 0)) { swModel.Extension.SelectByID2("Back3", "SHEET", 0, 0, 0, false, 0, null, 0); } } swModel.DeleteSelection(true); } else SheetNumering(swModel, swDrawing); } swModel.ForceRebuild3(false); bool writeXml = true; if (atLeastOneF1View) { try { writeXml=SomeLogicChanges(swModel); } catch(Exception e) { if (swModel.GetPathName() != null) Logging.Log.Instance.Fatal(e, "Ошибка при применении логики к XML. " + swModel.GetPathName()); else Logging.Log.Instance.Fatal(e, "Ошибка при применении логики к XML. "); } if (writeXml) StopWriteXml(pathXml); } return; }
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; }