Exemple #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());
            }
        }
        private string GetEleNameForCMM(Part ele)
        {
            ElectrodeNameInfo nameInfo = ElectrodeNameInfo.GetAttribute(ele);
            MoldInfo          moldInfo = MoldInfo.GetAttribute(ele);

            return(moldInfo.MoldNumber + "-" + moldInfo.WorkpieceNumber + "-E" + nameInfo.EleNumber.ToString());
        }
Exemple #3
0
        public ReplaceElectrode(Part pt, ElectrodeNameInfo newNameInfo)
        {
            this.elePt       = pt;
            this.oldNameInfo = ElectrodeNameInfo.GetAttribute(elePt);
            string oldPath = elePt.FullPath;

            this.directoryPath = Path.GetDirectoryName(oldPath) + "\\";
            this.newNameInfo   = newNameInfo;
        }
Exemple #4
0
        /// <summary>
        /// 获取电极名称
        /// </summary>
        /// <returns></returns>
        private ElectrodeNameInfo GetEleNameInfo()
        {
            ElectrodeNameInfo name = new ElectrodeNameInfo();

            name.EleName    = this.textBox_name.Text;
            name.EleNumber  = name.GetEleNumber(this.textBox_name.Text);
            name.BorrowName = "";
            return(name);
        }
Exemple #5
0
 /// <summary>
 /// 获取电极号
 /// </summary>
 /// <returns></returns>
 public string GetEleName()
 {
     if (ParentAssmblieInfo.IsElectrode(this.pt))
     {
         ElectrodeNameInfo name = ElectrodeNameInfo.GetAttribute(this.pt);
         if (pt.Name.Equals(name.EleName, StringComparison.CurrentCultureIgnoreCase))
         {
             return(name.EleName);
         }
     }
     return(pt.Name);
 }
Exemple #6
0
        /// <summary>
        /// 默认电极名
        /// </summary>
        /// <returns></returns>
        private string GetDefEleName(MoldInfo mold)
        {
            WorkCollection wc = new WorkCollection(mold);

            if (wc.Electrodes.Count == 0)
            {
                return(mold.MoldNumber + "-" + mold.WorkpieceNumber + "E1");
            }
            else
            {
                ElectrodeNameInfo nameInfo = (wc.Electrodes[wc.Electrodes.Count - 1].Info).AllInfo.Name;
                string            name     = nameInfo.EleName.Substring(0, nameInfo.EleName.LastIndexOf("E"));
                return(name + "E" + (nameInfo.EleNumber + 1).ToString());
            }
        }
Exemple #7
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);
        }