Example #1
0
        /// <summary>
        /// 获取work
        /// </summary>
        /// <param name="model"></param>
        /// <param name="asmPart"></param>
        /// <returns></returns>
        private WorkModel GetWorkModel(ElectrodeModel model)
        {
            List <NXOpen.Assemblies.Component> eleComs = AssmbliesUtils.GetPartComp(this.asmPart, model.PartTag);
            List <WorkModel> works = new List <WorkModel>();

            foreach (NXOpen.Assemblies.Component ct in eleComs)
            {
                NXOpen.Assemblies.Component parent = ct.Parent;
                if (parent != null)
                {
                    Part pt = parent.Prototype as Part;
                    if (WorkModel.IsWork(pt) && !works.Exists(a => a.PartTag.Equals(pt)) && ParentAssmblieInfo.GetAttribute(pt).MoldInfo.Equals(model.Info.MoldInfo))
                    {
                        works.Add(new WorkModel(pt));
                    }
                }
            }
            works.Sort();
            if (works.Count != 0)
            {
                return(works[0]);
            }
            else
            {
                return(null);
            }
        }
 public ElectrodeDrawingModel(WorkModel work, List <ElectrodeModel> eles)
 {
     this.Work     = work;
     this.Eles     = eles;
     this.PartType = "Drawing";
     this.EleInfo  = eles[0].EleInfo;
     this.MoldInfo = eles[0].MoldInfo;
     GetAssembleName();
     this.WorkpieceDirectoryPath = work.WorkpieceDirectoryPath;
     this.WorkpiecePath          = work.WorkpieceDirectoryPath + this.AssembleName + ".prt";
 }
Example #3
0
        public ElectrodeDrawingModel(List <ElectrodeModel> eleModels, Part asmPart, UserModel user)
        {
            this.eleModels = eleModels;
            this.asmPart   = asmPart;

            work = GetWorkModel(eleModels[0]);
            if (work == null)
            {
                throw new Exception("无法找到Work!");
            }
            Info = new ElectrodeDrawingInfo(eleModels[0].Info.MoldInfo, user, eleModels[0].Info.AllInfo);
        }
Example #4
0
 /// <summary>
 /// 添加Work
 /// </summary>
 /// <param name="work"></param>
 public void AddWork(WorkModel work)
 {
     if (!this.Works.Exists(x => x.AssembleName == work.AssembleName))
     {
         this.Works.Add(work);
     }
     else
     {
         WorkModel temp = this.Works.Find(x => x.AssembleName == work.AssembleName);
         this.Works.Remove(temp);
         this.Works.Add(work);
     }
 }
Example #5
0
        /// <summary>
        /// 获取全部装配
        /// </summary>
        private void GetAssembleInfo()
        {
            foreach (Part pt in Session.GetSession().Parts)
            {
                if (pt.Name.Length > moldAndWorkpieceNum.Length)
                {
                    if (moldAndWorkpieceNum.Equals(pt.Name.Substring(0, moldAndWorkpieceNum.Length))) //判断是否一个模号
                    {
                        string partType = AttributeUtils.GetAttrForString(pt, "PartType");

                        switch (partType)
                        {
                        case "ASM":
                        {
                            ASMModel asm = new ASMModel();
                            asm.GetModelForPart(pt);
                            this.Asm = asm;
                            break;
                        }

                        case "EDM":
                        {
                            EDMModel edm = new EDMModel();
                            edm.GetModelForPart(pt);
                            this.Edm = edm;
                            break;
                        }

                        case "Work":
                        {
                            WorkModel model = new WorkModel();
                            model.GetModelForPart(pt);
                            this.Works.Add(model);
                            break;
                        }

                        case "Electrode":
                        {
                            ElectrodeModel model = new ElectrodeModel();
                            model.GetModelForPart(pt);
                            this.Electrodes.Add(model);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
            }
        }
 public WorkDrawingModel(WorkModel work)
 {
     this.Work = work;
     workPart  = Session.GetSession().Parts.Work;
     GetWorkPieceComp();
 }