Example #1
0
        private void AlterEle(NXOpen.Assemblies.Component ct)
        {
            Part workPart = theSession.Parts.Work;
            Part pt       = ct.Prototype as Part;
            ElectrodeNameInfo newNameInfo = new ElectrodeNameInfo()
            {
                EleEditionNumber = this.strEleEditionNumber.Value.ToUpper(),
                EleName          = this.strEleName.Value + this.strEleName1.Value.ToUpper(),
            };

            newNameInfo.EleNumber = newNameInfo.GetEleNumber(newNameInfo.EleName);
            ReplaceElectrode el      = new ReplaceElectrode(pt, newNameInfo);
            Part             newPart = null;
            List <string>    err     = el.AlterEle(out newPart);

            if (newPart != null)
            {
                err.AddRange(el.AlterEleDra());
                List <NXObject> objs = AskEleAllInstance(newPart);
                if (objs.Count > 0)
                {
                    newNameInfo.SetAttribute(objs.ToArray());
                }
            }

            PartUtils.SetPartDisplay(workPart);

            if (err.Count > 0)
            {
                ClassItem.Print(err.ToArray());
            }
        }
Example #2
0
        private List <string> AlterElectrode(List <ElectrodeModel> eles, ParentAssmblieInfo info, bool isBorrow)
        {
            List <string> err  = new List <string>();
            string        temp = info.MoldInfo.MoldNumber + "-" + info.MoldInfo.WorkpieceNumber;

            info.Type = PartType.Electrode;
            foreach (ElectrodeModel em in eles)
            {
                string            old         = em.Info.MoldInfo.MoldNumber + "-" + em.Info.MoldInfo.WorkpieceNumber;
                ElectrodeNameInfo newNameInfo = em.Info.AllInfo.Name.Clone() as ElectrodeNameInfo;
                string            oldName     = em.Info.AllInfo.Name.EleName;
                string            newName     = oldName.Replace(old, temp);
                newNameInfo.EleName = newName;
                if (isBorrow)
                {
                    newNameInfo.BorrowName = oldName;
                }
                ReplaceElectrode rep = new ReplaceElectrode(em.PartTag, newNameInfo);
                err.AddRange(rep.AlterEle(info));
                err.AddRange(rep.AlterEleDra(em.Info, info));
            }
            return(err);
        }