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


C# ModelDoc2.FirstFeature方法代码示例

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


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

示例1: StorageModel

        /// <summary>
        /// Creates a StorageModel for reading and writing data on the given Model
        /// </summary>
        /// <param name="model">Model to read and write data keys from</param>
        public StorageModel(ModelDoc2 model)
        {
            this.model = model;
            data = new Dictionary<string, LinkedList<IAttribute>>();
            //storedDoubles = new Dictionary<string,List<double>>();
            storedObjects = new Dictionary<string,object>();
            //storedStrings = new Dictionary<string,List<string>>();
            Feature feat = model.FirstFeature(); //Start scan of robot attribute's sub-features
            IAttribute attr;
            nextID = 0;
            int id;
            string path;
            int stopindex;
            LinkedList<IAttribute> newlist;

            while (feat != null)  //Scan robot attribute's sub-features
            {
                if (feat.GetTypeName().Equals("Attribute"))
                {
                    attr = (IAttribute)feat.GetSpecificFeature2();
                    if (attr.GetName().StartsWith("gsim"))
                    {
                        stopindex = attr.GetName().IndexOf("_");
                        id = Convert.ToInt32(attr.GetName().Substring(4, stopindex-4));
                        if (id >= nextID)
                            nextID = id + 1;
                        path = ((IParameter)attr.GetParameter("name")).GetStringValue();
                        if (!data.ContainsKey(path))
                        {
                            newlist = new LinkedList<IAttribute>();
                            newlist.AddLast(attr);
                            data.Add(path, newlist);
                        }
                        else
                            data[path].AddLast(attr);
                    }
                }
                feat = feat.GetNextFeature();
            }
        }
开发者ID:FRCTeam159,项目名称:MentorRepository,代码行数:44,代码来源:StorageModel.cs

示例2: ReloadAllSetParameters


//.........这里部分代码省略.........
                                        commentsTb.Height = (size.Width / (commentsTb.Width - 10)) * 30;

                                    }
                                    catch
                                    {
                                        CommentLayout.Visible = false;
                                    }
                                }
                                rd.Close();

                            }
                            else
                            {
                                CommentLayout.Visible = false;
                            }
                            #endregion

                            #region Decors

                            if (!ReloadDecorTab(oleDb, oleSchem))
                                return;

                            #endregion

                            oleDb.Close();

                            #endregion
                        }
                    }
                    else
                        if (_tabDec != null)
                            tabMain.Controls.Remove(_tabDec);

                    var swFeat = (Feature)_swSelModel.FirstFeature();
                    i = 0;

                    #region Position

                    var mates = _swSelComp.GetMates();
                    Dictionary<string, Mate2> existingMates = new Dictionary<string, Mate2>();
                    if (mates != null)
                    {
                        foreach (var mate in mates)
                        {
                            if (mate is Mate2)
                            {
                                var spec = (Mate2)mate;
                                int mec = spec.GetMateEntityCount();
                                if (mec > 1)
                                {
                                    for (int ik = 0; ik < mec; ik++)
                                    {
                                        MateEntity2 me = spec.MateEntity(ik);
                                        if (me.ReferenceComponent.Name.Contains(_swSelComp.Name))
                                        {
                                            Entity tt = me.Reference;
                                            var tt2 = tt as Feature;

                                            if (tt is RefPlane && tt2 != null)
                                            {

                                                if (!existingMates.ContainsKey(tt2.Name))
                                                    existingMates.Add(tt2.Name, spec);
                                            }

                                        }
开发者ID:digger1985,项目名称:MyCode,代码行数:67,代码来源:frmSetParameters.cs

示例3: CheckAllMates

        private Component2 CheckAllMates(ModelDoc2 model, Component2 originalComp, string[] linkedModels, double[] sBox, string axe, out bool isLeft)
        {
            int axeInt = 0;
            switch (axe.ToLower())
            {
                case "x":
                    axeInt = 3;
                    break;
                case "y":
                    axeInt = 4;
                    break;
                case "z":
                    axeInt = 5;
                    break;
            }
            if (axeInt == 0)
                throw new Exception("Не удалось растянуть деталь. В mdb ref_objects_axe не правильно указана ось (axe).");
            isLeft = false;
            //model.ClosestDistance(origPlane, nearestPlane, out point1, out point2);
            var swFeat = (Feature)model.FirstFeature();
            while (swFeat != null)
            {

                if (swFeat.GetTypeName2() == "MateGroup")
                {
                    var mate = swFeat.GetFirstSubFeature();
                    while (mate != null)
                    {
                        if (mate.GetTypeName() == "MateCoincident")
                        {

                            Mate2 spec = mate.GetSpecificFeature2();

                            if (spec.GetMateEntityCount() > 1)
                            {
                                var paramsArray = spec.MateEntity(0).EntityParams as double[];
                                double tst = 0;
                                if (paramsArray != null && paramsArray.Length > axeInt)
                                    tst = paramsArray[axeInt];
                                if (spec.MateEntity(0).ReferenceComponent.Name.Contains(originalComp.Name) && (tst == 1 || tst == -1))
                                {
                                    foreach (string modelName in linkedModels)
                                    {
                                        if (spec.MateEntity(1).ReferenceComponent.Name.Contains(modelName))
                                        {
                                            double avarageZ = (sBox[axeInt - 3] + sBox[axeInt]) / 2;
                                            double[] mateBox = spec.MateEntity(1).ReferenceComponent.GetBox(false, false);
                                            double mateAvarageZ = (mateBox[axeInt - 3] + mateBox[axeInt]) / 2;
                                            if (avarageZ > mateAvarageZ)
                                                isLeft = false;
                                            else
                                                isLeft = true;
                                            return spec.MateEntity(1).ReferenceComponent;
                                        }
                                    }
                                }
                                paramsArray = spec.MateEntity(1).EntityParams as double[];
                                tst = 0;
                                if (paramsArray != null && paramsArray.Length > axeInt)
                                    tst = paramsArray[axeInt];
                                if (spec.MateEntity(1).ReferenceComponent.Name.Contains(originalComp.Name) && (tst == 1 || tst == -1))
                                {
                                    foreach (string modelName in linkedModels)
                                    {
                                        if (spec.MateEntity(0).ReferenceComponent.Name.Contains(modelName))
                                        {
                                            double avarageZ = (sBox[axeInt - 3] + sBox[axeInt]) / 2;
                                            double[] mateBox = spec.MateEntity(0).ReferenceComponent.GetBox(false, false);
                                            double mateAvarageZ = (mateBox[axeInt - 3] + mateBox[axeInt]) / 2;
                                            if (avarageZ > mateAvarageZ)
                                                isLeft = false;
                                            else
                                                isLeft = true;
                                            return spec.MateEntity(0).ReferenceComponent;
                                        }
                                    }
                                }
                            }
                        }
                        mate = mate.GetNextSubFeature();
                    }
                }
                swFeat = (Feature)swFeat.GetNextFeature();
            }
            return null;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:86,代码来源:frmSetParameters.cs

示例4: GetFeatureByName

        internal static bool GetFeatureByName(ModelDoc2 inModel, string inName, out Feature outFeature)
        {
            Feature swSubFeature;
            bool ret = false;

            outFeature = (Feature)inModel.FirstFeature();

            while (outFeature != null)
            {
                if (outFeature.Name == inName)
                {
                    ret = true;
                    break;
                }
                swSubFeature = (Feature)outFeature.GetFirstSubFeature();

                while (swSubFeature != null)
                {
                    if (swSubFeature.Name.ToLower() == inName.ToLower())
                    {
                        ret = true;
                        break;
                    }
                    swSubFeature = (Feature)swSubFeature.GetNextSubFeature();
                }
                if (ret) break;

                outFeature = (Feature)outFeature.GetNextFeature();
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:31,代码来源:SwAddin.cs

示例5: RecalculateModel


//.........这里部分代码省略.........
                                        cm = new OleDbCommand("SELECT * FROM objects " + "WHERE id=" +
                                                              Strings.Right(strFieldName, strFieldName.Length - 3) +
                                                              " AND ismaster=false", oleDb);
                                        OleDbDataReader rdSlave = cm.ExecuteReader();

                                        if (rdSlave.Read())
                                        {
                                            double val = 0;
                                            switch ((int)rdSlave["type"])
                                            {
                                                case 14:
                                                    val = (double)rdData[i];
                                                    break;

                                                case 20:
                                                case 22:
                                                    val = (bool)rdData[i] ? 1 : 0;
                                                    break;
                                            }
                                            // bool? noArtIfSuppressed = rdSlave["noArtIfSuppressed"] as bool?;
                                            bool noArtIfSuppressed = false;

                                            try
                                            {
                                                if (rdSlave["noArtIfSuppressed"] as bool? != null)
                                                {
                                                    noArtIfSuppressed = (bool)rdSlave["noArtIfSuppressed"];
                                                }
                                            }
                                            catch (Exception)
                                            { }

                                            //MessageBox.Show(Path.GetFileNameWithoutExtension(inModel.GetPathName()) + " " + rdSlave["name"] + " " + val);
                                            SetObjectValue(inModel, rdSlave["name"].ToString(), (int)rdSlave["type"], val, (bool)noArtIfSuppressed);
                                        }
                                        rdSlave.Close();
                                    }
                                }
                                rdData.Close();

                            }
                        }
                        rdSource.Close();

                        if (oleSchem.Rows.Cast<DataRow>().Any(row => (string)row["TABLE_NAME"] == "equations"))
                        {
                            cm = new OleDbCommand("SELECT * FROM equations ORDER BY id", oleDb);
                            OleDbDataReader rdEqu = cm.ExecuteReader();

                            while (rdEqu.Read())
                            {
                                if (GetObjectValue(inModel, rdEqu["master"].ToString(), 14, out strObjVal))
                                {
                                    SetObjectValue(inModel, rdEqu["slave"].ToString(), 14, strObjVal);
                                }
                            }
                            rdEqu.Close();
                        }
                    }
                    oleDb.Close();

                    //�������������� ��������� ���������� � �������
                    Feature swSubFeature;
                    var swFeature = (Feature)inModel.FirstFeature();

                    bool isFeatureFound = false;

                    while (swFeature != null)
                    {
                        if (swFeature.GetTypeName2() == "MateGroup")
                        {
                            isFeatureFound = true;

                            swSubFeature = (Feature)swFeature.GetFirstSubFeature();
                            while (swSubFeature != null)
                            {
                                if (swSubFeature.GetErrorCode() != (int)swFeatureError_e.swFeatureErrorNone)
                                {
                                    swSubFeature.IsSuppressed2((int)swInConfigurationOpts_e.swThisConfiguration, null);
                                    swSubFeature.SetSuppression((int)swFeatureSuppressionAction_e.swSuppressFeature);
                                }
                                swSubFeature = (Feature)swSubFeature.GetNextSubFeature();
                            }
                        }
                        if (isFeatureFound) break;
                        swFeature = (Feature)swFeature.GetNextFeature();
                    }
                    ret = true;
                }

                _features.Clear();
                _comps.Clear();
            }

            catch (Exception e)
            {
                MessageBox.Show(e.Message, MyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:SwAddin.cs


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