Esempio n. 1
0
        public void TraverseComponent(Component2 swComp)
        {
            string name = swComp.Name2;

            object[]   vChildComp;
            Component2 swChildComp;


            vChildComp = (object[])swComp.GetChildren();
            for (int i = 0; i < vChildComp.Length; i++)
            {
                swChildComp = (Component2)vChildComp[i];
                TraverseComponent(swChildComp);
            }
            try
            {
                ModelDoc2 compMdl = (ModelDoc2)swComp.GetModelDoc2();

                if (compMdl != null)
                {
                    string mdlName = Path.GetFileName(compMdl.GetPathName());
                    string refCfg  = swComp.ReferencedConfiguration;

                    string newConfig = GetNewConfig(mdlName, refCfg);
                    if (!string.IsNullOrEmpty(newConfig))
                    {
                        ModifyComponent comp = new ModifyComponent(swComp, refCfg, newConfig);
                        comp.Change();

                        swComp.Select(false);
                        AssemblyDoc assem = (AssemblyDoc)iSwApp.ActiveDoc;

                        assem.CompConfigProperties4(2, 0, true, true, newConfig, false);
                    }
                }
            }
            catch
            {
            }
        }