/// <summary> /// 主工件图 /// </summary> /// <param name="workpiecePart"></param> private void HostWorkpieceDrawing(double scale) { Part workPart = Session.GetSession().Parts.Work; DrawingSheet[] st = workPart.DrawingSheets.ToArray(); if (st.Length > 0) { DeleteObject.Delete(st); } this.originPoint = PointUtils.CreatePointFeature(this.work.Info.Matr.GetCenter()); WorkpieceDrawing dra = new WorkpieceDrawing(hostDraw, work, workDra, this.originPoint); try { NXOpen.Drawings.DrawingSheet sheet = Basic.DrawingUtils.DrawingSheet(workpieceDrawTemplate, 297, 420, workDra.HostComp[0].Name); dra.CreateView(scale, GetFirstPoint(hostDraw, scale), this.workpieceTablePath); double[] plistOrigin = { 180, 120, 0 }; Basic.DrawingUtils.CreatePlist(plistPath, plistOrigin); Basic.DrawingUtils.UpdateViews(sheet); } catch (NXException ex) { ClassItem.WriteLogFile(hostDraw.WorkpiecePart.Name + "创建图纸错误! " + ex.Message); return; } }
/// <summary> /// 创建一张其他工件图 /// </summary> /// <param name="other"></param> /// <param name="scale"></param> private void OtherWorkpieceView(List <WorkpieceDrawingModel> other, double scale) { Point3d firstPt = GetFirstPoint(other[0], scale); double length = 0; foreach (WorkpieceDrawingModel wk in other) { length += 2 * wk.DisPt.X * scale; } int k = 0; if (other.Count == 1) { k = 0; } else { k = (int)Math.Floor(300 - length) / (other.Count - 1); } NXOpen.Drawings.DrawingSheet sheet = Basic.DrawingUtils.DrawingSheet(workpieceDrawTemplate, 297, 420, other[0].WorkpiecePart.Name); for (int i = 0; i < other.Count; i++) { Point3d temp; if (i == 0) { temp = firstPt; } else { double x = other[i - 1].DisPt.X * scale + other[i].DisPt.X * scale + i * k; temp = new Point3d(firstPt.X + x, firstPt.Y, firstPt.Z); } WorkpieceDrawing wd = new WorkpieceDrawing(other[i], this.work, workDra, this.originPoint); wd.CreateView(scale, temp, this.workpieceTablePath); } Basic.DrawingUtils.UpdateViews(sheet); }
private void CreateView(double scale, Point3d originPt, WorkpieceInfo info) { WorkpieceDrawing dra = new WorkpieceDrawing(work, info, originPoint); dra.CreateView(scale, originPt, this.workpieceTablePath); }