Ejemplo n.º 1
0
        /// <summary>
        /// 拷贝同件号
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public List <string> CopWork(UserModel user)
        {
            List <string>  err      = new List <string>();
            WorkInfo       workInfo = work.Info.Clone() as WorkInfo;
            WorkCollection workColl = new WorkCollection(workInfo.MoldInfo);
            int            workNum  = workColl.Work[workColl.Work.Count - 1].Info.WorkNumber + 1;

            workInfo.WorkNumber = workNum;
            workInfo.UserModel  = user;
            EDMModel edm = GetEDMModel();

            if (edm != null)
            {
                WorkCreateAssmbile create = new WorkCreateAssmbile(workInfo, edm, asm);
                err.AddRange(create.CreatePart(work.WorkpieceDirectoryPath));
                err.AddRange(create.LoadAssmbile());
                if (err.Count == 0)
                {
                    create.Work.SaveCsys(asm.PartTag);
                }
                foreach (NXOpen.Assemblies.Component elect in GetElectrodeComponent())
                {
                    err.AddRange(LoadEle(elect, create.Work.PartTag));
                }
            }
            else
            {
                err.Add("无法获取EDM");
            }

            return(err);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建Work
        /// </summary>
        /// <param name="user"></param>
        /// <param name="workpieceCt"></param>
        /// <returns></returns>
        public List <string> CreateWork(UserModel user, NXOpen.Assemblies.Component workpieceCt, Matrix4 mat)
        {
            List <string>  err            = new List <string>();
            WorkpieceModel workpieceModel = new WorkpieceModel(workpieceCt.Prototype as Part);
            WorkInfo       workInfo       = work.Info.Clone() as WorkInfo;
            WorkCollection workColl       = new WorkCollection(workpieceModel.Info.MoldInfo);
            int            workNum        = 1;

            if (workColl.Work.Count > 0)
            {
                workNum = workColl.Work[workColl.Work.Count - 1].Info.WorkNumber + 1;
            }
            workInfo.WorkNumber = workNum;
            workInfo.UserModel  = user;
            workInfo.Matr       = mat;
            workInfo.MatrInfo   = new Matrix4Info(mat);
            EDMModel edmModel;
            bool     isOther = false;

            if (workpieceModel.Info.MoldInfo.Equals(work.Info.MoldInfo))
            {
                edmModel = GetEDMModel();
            }
            else
            {
                workInfo.MoldInfo = workpieceModel.Info.MoldInfo;
                EDMInfo info = new EDMInfo(workpieceModel.Info.MoldInfo, user);
                edmModel = new EDMModel(info);
                isOther  = true;
            }
            WorkCreateAssmbile create = new WorkCreateAssmbile(workInfo, edmModel, asm);

            err.AddRange(create.CreatePart(work.WorkpieceDirectoryPath));
            err.AddRange(create.LoadAssmbile());
            if (err.Count == 0)
            {
                create.Work.SaveCsys(asm.PartTag);
            }
            if (isOther)
            {
                err.AddRange(LoadWorkpiece(edmModel.PartTag, workpieceCt));
            }
            return(err);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 拷贝不用件号的work
        /// </summary>
        /// <param name="user"></param>
        /// <param name="workpieceName"></param>
        /// <returns></returns>
        public List <string> CopOtherWork(UserModel user, string workpieceName)
        {
            List <string> err = new List <string>();

            NXOpen.Assemblies.Component ct = GetWorkpieceModelForName(workpieceName);
            if (ct == null)
            {
                err.Add("无法找到工件!");
            }
            else
            {
                WorkpieceModel model    = new WorkpieceModel(ct.Prototype as Part);
                WorkInfo       workInfo = work.Info.Clone() as WorkInfo;
                WorkCollection workColl = new WorkCollection(model.Info.MoldInfo);
                int            workNum  = workColl.Work.Count + 1;
                workInfo.WorkNumber = workNum;
                workInfo.UserModel  = user;
                workInfo.MoldInfo   = model.Info.MoldInfo;
                EDMInfo  edmInfo  = new EDMInfo(model.Info.MoldInfo, user);
                EDMModel edmModel = new EDMModel(edmInfo);
                GetEDMName(ref edmModel);
                WorkCreateAssmbile create = new WorkCreateAssmbile(workInfo, edmModel, asm);
                err.AddRange(create.CreatePart(work.WorkpieceDirectoryPath));
                err.AddRange(create.LoadAssmbile());
                if (err.Count == 0)
                {
                    create.Work.SaveCsys(asm.PartTag);
                }
                foreach (NXOpen.Assemblies.Component elect in GetElectrodeComponent())
                {
                    err.AddRange(LoadEle(elect, create.Work.PartTag));
                }
                err.AddRange(LoadWorkpiece(edmModel.PartTag, ct));
            }
            return(err);
        }