Exemplo n.º 1
0
        internal static List<DecorsListS> GetListComponentForDecors(SwAddin swAddin, OleDbDataReader reader, LinkedList<Component2> components)
        {
            var listDetailComps = components.Select(x => x.IGetModelDoc()).Where(x => x != null
                                                                                          &&
                                                                                          x.GetType() ==
                                                                                          (int)
                                                                                          swDocumentTypes_e
                                                                                              .swDocPART)
                    .Select(
                        x => Path.GetFileNameWithoutExtension(swAddin.
                                                                  GetModelNameWithoutSuffix(
                                                                      x.GetPathName())));

            var decorsLists = new List<DecorsListS>();
            int i = 0;
            while (reader.Read())
            {
                //if(listDetailComps.Contains((string)reader["Element"]))
                string rr = (string)reader["Element"];
                if (listDetailComps.Where(x => x.Contains(rr)).FirstOrDefault() != null)
                {
                    var numbPos = Convert.ToInt32(reader["Number"]);
                    if (numbPos != i)
                    {
                        foreach (var component2 in components)
                        {
                            if (component2.IsSuppressed()) continue;
                            //if (Path.GetFileNameWithoutExtension(swAddin.GetModelNameWithoutSuffix(component2.GetPathName()))== ((string)reader["Element"]))
                            if (Path.GetFileNameWithoutExtension(swAddin.GetModelNameWithoutSuffix(component2.GetPathName())).Contains((string)reader["Element"]))
                            {
                                decorsLists.Add(new DecorsListS((int)reader["Number"], component2));
                                break;
                            }
                        }
                        i = numbPos;
                    }
                }
            }
            return decorsLists;
        }
Exemplo n.º 2
0
        internal static List<DimensionConfiguration> GetListComponentForDimension(SwAddin swAddin, OleDbDataReader reader, LinkedList<Component2> components)
        {
            var listDetailComps = components.Select(x => x.IGetModelDoc()).Where(x => x != null)
                    .Select(
                        x => Path.GetFileNameWithoutExtension(swAddin.
                                                                  GetModelNameWithoutSuffix(
                                                                      x.GetPathName()))).ToArray();
            string tmpChar;
            string[] listDetailCompTmp = new string[listDetailComps.Count()];
            int ii = 0;
            foreach (var listDetailComp in listDetailComps)
            {
                if (listDetailComp.Length < 6)
                {
                    listDetailCompTmp[ii] = listDetailComp;
                    ii++;
                    continue;
                }
                tmpChar = listDetailComp.Substring(listDetailComp.Length - 4, 1);
                if ((listDetailComp.Last() == 'P' || listDetailComp.Last() == 'p') && (tmpChar == "#"))
                    listDetailCompTmp[ii] = listDetailComp.Substring(0, listDetailComp.Length - 4);
                else
                    listDetailCompTmp[ii] = listDetailComp;
                ii++;
            }
            //listDetailComps = new string[listDetailCompTmp.Length];
            listDetailComps = listDetailCompTmp;
            var decorsLists = new List<DimensionConfiguration>();
            int i = 0;
            while (reader.Read())
            {
                if (listDetailComps.Contains((string)reader["element"]))
                {
                    var numbPos = Convert.ToInt32(reader["number"]);

                    if (numbPos != i)
                    {
                        List<Component2> compsWithNumberCopies = new List<Component2>();
                        foreach (var comp in components)
                        {
                            string fileName = Path.GetFileNameWithoutExtension(swAddin.GetModelNameWithoutSuffix(comp.GetPathName()));
                            int rIndex = fileName.LastIndexOf('#');
                            if (rIndex != -1)
                                fileName = fileName.Remove(rIndex, fileName.Length - rIndex);
                            if (fileName == (string)reader["Element"])
                                compsWithNumberCopies.Add(comp);
                        }

                        try
                        {
                            compsWithNumberCopies.Sort(
                                (x, y) =>
                                Convert.ToInt32(x.Name.Substring(x.Name.LastIndexOf('-') + 1)).CompareTo(
                                    Convert.ToInt32(y.Name.Substring(y.Name.LastIndexOf('-') + 1))));

                        }
                        catch { }
                        if (compsWithNumberCopies.Count > 0)
                        {
                            Component2 neededComp = compsWithNumberCopies.First();
                            decorsLists.Add(new DimensionConfiguration((int)reader["number"], neededComp,
                                                                       (string)reader["caption"],
                                                                       (string)reader["idslave"], (int)reader["id"]));
                        }
                        i = numbPos;
                    }
                }
            }
            return decorsLists;
        }
Exemplo n.º 3
0
        internal static List<Component2> GetConfigComponents(SwAddin swAddin, ModelDoc2 model, int configNumber)
        {
            List<Component2> outComps = new List<Component2>();

            List<string> compsNames = GetComponentsNamesOnConfiguration(swAddin, model, configNumber);

            LinkedList<Component2> modelComponents = new LinkedList<Component2>();
            swAddin.GetComponents(model.IGetActiveConfiguration().IGetRootComponent2(), modelComponents, true, false);

            foreach (var component in modelComponents)
            {
                if (component.IsSuppressed()) continue;
                string compName = Path.GetFileNameWithoutExtension(swAddin.GetModelNameWithoutSuffix(component.GetPathName()));

                foreach (string name in compsNames)
                {
                    if (compName.Contains(name))
                    {
                        outComps.Add(component);
                        break;
                    }
                }
            }
            return outComps;
        }