当前位置: 首页>>代码示例>>C#>>正文


C# ModelDoc2.DeleteSelection方法代码示例

本文整理汇总了C#中ModelDoc2.DeleteSelection方法的典型用法代码示例。如果您正苦于以下问题:C# ModelDoc2.DeleteSelection方法的具体用法?C# ModelDoc2.DeleteSelection怎么用?C# ModelDoc2.DeleteSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelDoc2的用法示例。


在下文中一共展示了ModelDoc2.DeleteSelection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrepareDrawingDoc


//.........这里部分代码省略.........
                if (swDoc != null)
                {
                    SwDMSearchOption src = swDocMgr.GetSearchOptionObject();
                    object brokenRefVar;
                    var varRef = (object[])swDoc.GetAllExternalReferences2(src, out brokenRefVar);
                    var name = (string)varRef[0];
                    swAsmModel = outModels.FirstOrDefault(modelDoc2 => modelDoc2.GetPathName() == name);
                }
            */
            ModelDoc2 swAsmModel = GetCurrentAsmModel(swModel);

            OleDbConnection oleDb;
            if (swAsmModel != null)
            {
                if (_createProgramm)
                {
                    var matName = swAsmModel.get_CustomInfo2("", "Material");
                    if (matName == "" && swAsmModel.GetConfigurationCount() > 1)
                    {
                        string val, resolvedVal;
                        if (
                            swAsmModel.Extension.get_CustomPropertyManager(swAsmModel.IGetActiveConfiguration().Name).
                                Get4(
                                    "Material", false, out val, out resolvedVal))
                            matName = val;
                    }
                    _z = ParseMaterialName(matName);
                }

                if (_swAdd.OpenModelDatabase(swAsmModel, out oleDb))
                {
                    bool isPropName, isStdSketchNum, isSheetNames;
                    if (IsNeededColumnInDbFile(oleDb, out isPropName, out isStdSketchNum, out isSheetNames))
                    {
                        var objNames = _namesOfColumnNameFromDimLimits.Where(x => x.Contains("obj"));
                        var listId = new List<int>();
                        foreach (var objName in objNames)
                        {
                            int id = FrmSetParameters.GetIdFromColumnName(objName);
                            if (!listId.Contains(id))
                                listId.Add(id);
                        }
                        var dictIdSize = new Dictionary<int, double>();
                        var cm = new OleDbCommand("SELECT * FROM objects", oleDb);
                        var rd = cm.ExecuteReader();
                        while (rd.Read())
                        {
                            if (listId.Contains((int) rd["id"]))
                            {
                                double val;
                                if (_swAdd.GetObjectValue(swAsmModel, (string) rd["name"], 14, out val) &&
                                    !dictIdSize.ContainsKey((int) rd["id"]))
                                    dictIdSize.Add((int) rd["id"], val);
                            }
                        }
                        rd.Close();
                        cm = new OleDbCommand("SELECT * FROM dimlimits", oleDb);
                        rd = cm.ExecuteReader();
                        while (rd.Read())
                        {
                            var lB = (from i in listId
                                      let mn = (int) rd["obj" + i + "min"]
                                      let mx = (int) rd["obj" + i + "max"]
                                      select (mn <= dictIdSize[i]) && (dictIdSize[i] <= mx)).ToList();
                            if (lB.Aggregate(true, (current, b) => (b && current)))
                            {
                                if (isSheetNames)
                                {
                                    var needSheetsNumb = (string) rd["sheetnames"];
                                    swModel.ClearSelection();
                                    foreach (var strNum in needSheetsNumb.Split(','))
                                    {
                                        string strNm = strNum.Trim();
                                        string num = strNm.Substring(0, strNm.Length - 1);
                                        string side = strNm.Substring(strNm.Length - 1);
                                        list.Add(num, side.ToLower() == "l");
                                    }
                                    var swDrw = (DrawingDoc) swModel;
                                    var sheetnames = (string[]) swDrw.GetSheetNames();

                                    foreach (var sheetname in sheetnames)
                                    {
                                        if (sheetname.Contains("1") ||
                                            list.Keys.Contains(sheetname.Substring(sheetname.Length - 1)))
                                            continue;
                                        swModel.Extension.SelectByID2(sheetname, "SHEET", 0, 0, 0, true, 0, null, 0);
                                    }
                                    swModel.DeleteSelection(true);
                                    ret = true;
                                }
                                break;
                            }
                        }
                        rd.Close();
                    }
                    oleDb.Close();
                }
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:DimensionDraft.cs

示例2: AutoDimensionDrawing2


//.........这里部分代码省略.........
                                    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;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:DimensionDraft.cs

示例3: GetCutComponents

        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;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:68,代码来源:SwAddin.cs


注:本文中的ModelDoc2.DeleteSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。