예제 #1
0
파일: Planes.cs 프로젝트: digger1985/MyCode
 public static string GetName(Planes.Type type)
 {
     switch (type)
     {
         case Type.Left:
             return "#Левая";
         case Type.Right:
             return "#Правая";
         case Type.Top:
             return "#Верхняя";
         case Type.Bottom:
             return "#Нижняя";
         case Type.Front:
             return "#Передняя";
         case Type.Back:
             return "#Задняя";
         case Type.swrfLeft:
             return "#swrfЛевая";
         case Type.swrfRight:
             return "#swrfПравая";
         case Type.swrfTop:
             return "#swrfВерхняя";
         case Type.swrfBottom:
             return "#swrfНижняя";
         case Type.swrfFront:
             return "#swrfПередняя";
         case Type.swrfBack:
             return "#swrfЗадняя";
         default:
             throw new ArgumentException();
     }
 }
예제 #2
0
            public Component2 GetNeighborStand2(SwAddin SwAddin, Planes.Type plane)
            {
                Component2 currentStand = null;
                string currentStandName;
                dynamic currentStandMates;

                string neighborStandPlane = "";
                switch (plane)
                {
                    case Planes.Type.Left:
                        neighborStandPlane = Planes.GetName(Planes.Type.Right);
                        break;
                    case Planes.Type.Right:
                        neighborStandPlane = Planes.GetName(Planes.Type.Left);
                        break;
                }

                bool searchFinished = false;
                Measure measure = SwAddin.RootModel.Extension.CreateMeasure();
                bool findComp;
                string projectName = Path.GetFileNameWithoutExtension(SwAddin.RootModel.GetPathName());
                //а если его просто нет?
                while (!searchFinished)
                {
                    findComp = false;
                    if (currentStand == null)
                    {
                        currentStandMates = this.Component.GetMates();
                        currentStandName = this.Component.Name;
                    }
                    else
                    {
                        currentStandMates = currentStand.GetMates();
                        currentStandName = currentStand.Name;
                    }

                    foreach (var mate in currentStandMates)
                    {
                        if (mate is Mate2)
                        {
                            Mate2 spec = (Mate2)mate;
                            int mec = spec.GetMateEntityCount();
                            if (mec > 1)
                            {
                                for (int ik = 0; ik < mec; ik++)
                                {
                                    MateEntity2 me = spec.MateEntity(ik);
                                    string name = me.ReferenceComponent.Name;
                                    if (!name.Contains(currentStandName))
                                    {
                                        Component2 mateStand = me.ReferenceComponent;
                                        string filePath = mateStand.GetPathName();
                                        SwDMApplication swDocMgr = SwAddin.GetSwDmApp();
                                        SwDmDocumentOpenError oe;
                                        var swDoc = swDocMgr.GetDocument(filePath, SwDmDocumentType.swDmDocumentUnknown, true, out oe);
                                        SwDmCustomInfoType swDmCstInfoType;
                                        string valueOfName = "";
                                        //todo: говнокод детектед
                                        try
                                        {
                                            valueOfName = swDoc.GetCustomProperty("KitchenType", out swDmCstInfoType);
                                        }
                                        catch { }
                                        if (valueOfName.ToLower().Contains("тумба"))
                                        {
                                            SwAddin.RootModel.ClearSelection();
                                            SwAddin.RootModel.Extension.SelectByID2(string.Format("{0}@{1}@{2}", Planes.GetName(plane), currentStand.Name, projectName), "PLANE", 0, 0, 0, false, 0, null, 0);
                                            SwAddin.RootModel.Extension.SelectByID2(string.Format("{0}@{1}@{2}", neighborStandPlane, mateStand.Name, projectName), "PLANE", 0, 0, 0, true, 0, null, 0);
                                            measure.Calculate(null);

                                            if (measure.IsIntersect && measure.IsParallel)
                                            {
                                                currentStand = mateStand;
                                                findComp = true;
                                            }
                                            SwAddin.RootModel.ClearSelection();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    searchFinished = !findComp;
                }
                return currentStand;
            }