Esempio n. 1
0
        /// <summary>
        /// 获取比例
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private double GetScale(WorkpieceInfo info)
        {
            double x = 120 / (info.DisPt.X * 2);
            double y = 160 / (info.DisPt.Y * 2 + info.DisPt.Z * 2);

            if (x > y)
            {
                if (y > 1)
                {
                    return(Math.Floor(y));
                }
                else
                {
                    return(Math.Round(y, 1));
                }
            }
            else
            {
                if (x > 1)
                {
                    return(Math.Floor(x));
                }
                else
                {
                    return(Math.Round(x, 1));
                }
            }
        }
Esempio n. 2
0
        private void OtherWorkpieceDrawing(List <WorkpieceInfo> otherPart, WorkpieceInfo hostInfo, double scale)
        {
            int count = (int)Math.Floor(340 / (2 * hostInfo.DisPt.X * scale + 40));
            List <WorkpieceInfo> other = otherPart.OrderBy(a => a.workpiece.Name).ToList();
            int temp = 0;

            for (int i = 0; i < other.Count; i++)
            {
                List <WorkpieceInfo> infos = new List <WorkpieceInfo>();
                for (int k = 0; k < count; k++)
                {
                    if (k + i < other.Count)
                    {
                        infos.Add(other[k + i]);
                    }
                    else
                    {
                        break;
                    }
                }
                temp++;
                OtherWorkpieceView(infos, scale);
                i = temp * count - 1;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取第一个设定点
        /// </summary>
        /// <param name="info"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        private Point3d GetFirstPoint(WorkpieceInfo info, double scale)
        {
            Point3d pt = new Point3d(0, 0, 0);

            pt.X = 50 + (info.DisPt.X) * scale;
            pt.Y = 250 - (info.DisPt.Y) * scale;
            return(pt);
        }
Esempio n. 4
0
 /// <summary>
 /// 主工件图
 /// </summary>
 /// <param name="workpiecePart"></param>
 private void HostWorkpieceDrawing(Part workpiecePart, WorkpieceInfo info, double scale)
 {
     NXOpen.Drawings.DrawingSheet sheet = Basic.DrawingUtils.DrawingSheetByName(workpiecePart.Name);
     if (sheet != null)
     {
         DeleteObject.Delete(sheet);
     }
     sheet = Basic.DrawingUtils.DrawingSheet(workpieceDrawTemplate, 297, 420, workpiecePart.Name);
     this.CreateView(scale, this.GetFirstPoint(info, scale), info);
     double[] plistOrigin = { 204, 70, 0 };
     Basic.DrawingUtils.CreatePlist(plistPath, plistOrigin);
     Basic.DrawingUtils.UpdateViews(sheet);
 }
Esempio n. 5
0
        public bool CreateDrawing()
        {
            Part workPart = Session.GetSession().Parts.Work;

            if (!workPart.Name.Equals(this.work.AssembleName))
            {
                PartUtils.SetPartDisplay(this.work.PartTag);
            }
            string               workpiece = this.work.MoldInfo.MoldNumber + "-" + this.work.MoldInfo.WorkpieceNumber + this.work.MoldInfo.EditionNumber;
            WorkpieceInfo        info      = null;
            List <WorkpieceInfo> otherPart = new List <WorkpieceInfo>();

            foreach (Part part in this.assemble.Workpieces)
            {
                if (workpiece.Replace("-", "").Equals(part.Name.Replace("-", "")))
                {
                    info = new WorkpieceInfo(part, work);
                }
                else
                {
                    otherPart.Add(new WorkpieceInfo(part, this.work));
                }
            }
            if (info == null)
            {
                return(false);
            }

            double scale = GetScale(info);

            CreatePointAndCenterLine(info.CenterPt, info.DisPt);
            HostWorkpieceDrawing(info.workpiece, info, scale);
            if (otherPart.Count > 0)
            {
                OtherWorkpieceDrawing(otherPart, info, scale);
            }
            return(true);
        }
Esempio n. 6
0
 public WorkpieceDrawing(WorkModel work, WorkpieceInfo workpiece, Point originPoint)
 {
     this.work        = work;
     this.workpiece   = workpiece;
     this.originPoint = originPoint;
 }
Esempio n. 7
0
        private void CreateView(double scale, Point3d originPt, WorkpieceInfo info)
        {
            WorkpieceDrawing dra = new WorkpieceDrawing(work, info, originPoint);

            dra.CreateView(scale, originPt, this.workpieceTablePath);
        }