protected ToolComp toolCompChecker(string par, string tokenInfo) { ToolComp comp = ToolComp.None; if (string.IsNullOrEmpty(par)) { return(comp); } if (par.ToUpper() == "R") { comp = ToolComp.Right; } else if (par.ToUpper() == "L") { comp = ToolComp.Left; } else { this.isValid = false; this.writeError(string.Format("机加工指令{0}参数错误,错误值:{1}", tokenInfo, par), false); } return(comp); }
/// <summary> /// Get the absolute robot coordinates (Used for Line elements: Trigger) /// </summary> /// <param name="distance">Distance along the Loc vector (angle of Yaw) </param> /// <param name="applyToolOffset"> Ad the too offset to adjust for tool moounting position</param> /// <returns></returns> public G3DPoint GetRobotLoc(Millimeters distance, bool applyToolOffset) { if (Loc.XYYawMode == G3DPoint.eMode.Absolute) { double x = distance * Math.Cos(Loc.Yaw); double y = distance * Math.Sin(Loc.Yaw); if (Loc.ZMode == G3DPoint.eMode.Absolute) { return(new G3DPoint(Loc.X + x, Loc.Y + y, Loc.Z)); } else { return(new G3DPoint(Loc.X + x, Loc.Y + y, 0)); } } G3DPoint pt = TransformXY(distance, 0); if (Loc.ZMode == G3DPoint.eMode.Absolute) { pt.Z.Val = Loc.Z; } else { pt.Z.Val = TransformZ(0); } if (applyToolOffset && ToolComp != null) { if (_offsetComp == null && _offsetCompCheck == false) { _offsetComp = ToolComp.FilterByTypeSingle <G3DCompBase>(); _offsetCompCheck = true; } if (_offsetComp != null) { pt.X += _offsetComp.Loc.X; pt.Y += _offsetComp.Loc.Y; if (Loc.ZMode == G3DPoint.eMode.Relative) { pt.Z += _offsetComp.Loc.Z; } } } return(pt); }
public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile) { //指令根据板件的1-4个边进行定位 //需要根据面的方位来生成加工的位置 //幸运的是,不需要经过太多的坐标转换 List <Point3d> Points = new List <Point3d>(); ToolComp comp = ToolComp.None; if (EdgeNumber == 1) { Point3d firstPt = new Point3d(StartX, -LeadIn, Depth); Point3d secondPt = new Point3d(StartX, StartY, Depth); Point3d thirdPt = new Point3d(EndX, EndY, Depth); Point3d forthPt = new Point3d(EndX, -LeadIn, Depth); Points.Add(firstPt); Points.Add(secondPt); Points.Add(thirdPt); Points.Add(forthPt); comp = ToolComp.Left; Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = Points; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); } else if (EdgeNumber == 2) { //double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length; double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length; Point3d firstPt = new Point3d(StartX, pw + LeadIn, Depth); Point3d secondPt = new Point3d(StartX, pw - StartY, Depth); Point3d thirdPt = new Point3d(EndX, pw - EndY, Depth); Point3d forthPt = new Point3d(EndX, pw + LeadIn, Depth); Points.Add(firstPt); Points.Add(secondPt); Points.Add(thirdPt); Points.Add(forthPt); comp = ToolComp.Right; Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = Points; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); } else if (EdgeNumber == 3) { //double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length; //double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length; Point3d firstPt = new Point3d(-LeadIn, StartY, Depth); Point3d secondPt = new Point3d(StartX, StartY, Depth); Point3d thirdPt = new Point3d(EndX, EndY, Depth); Point3d forthPt = new Point3d(-LeadIn, EndY, Depth); Points.Add(firstPt); Points.Add(secondPt); Points.Add(thirdPt); Points.Add(forthPt); comp = ToolComp.Right; Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = Points; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); } else if (EdgeNumber == 4) { double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length; //double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length; Point3d firstPt = new Point3d(pl + LeadIn, StartY, Depth); Point3d secondPt = new Point3d(pl - StartX, StartY, Depth); Point3d thirdPt = new Point3d(pl - EndX, EndY, Depth); Point3d forthPt = new Point3d(pl + LeadIn, EndY, Depth); Points.Add(firstPt); Points.Add(secondPt); Points.Add(thirdPt); Points.Add(forthPt); comp = ToolComp.Left; Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = Points; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); } }
public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile) { //先以当前点为坐标系,建立两点坐标 double xydist = System.Math.Sqrt(DistX * DistX + DistY * DistY); double cos = DistX / xydist; double sin = DistY / xydist; Point3d firstPt = new Point3d(DistX + LeadIn * cos, -LeadIn * sin, Depth); Point3d secondPt = new Point3d(-LeadIn * cos, DistY + LeadIn * sin, Depth); //把两点坐标,转换为世界坐标,再转为MP坐标系 Point3d pt = Part.GetPartPointByNumber(EdgeNumber.ToString()); Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem( Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, pt, (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber), (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber), Vector3d.ZAxis); Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem( Part.MPPoint, Part.MPXAxis, Part.MPYAxis, Part.MPZAxis, Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis); firstPt = firstPt.TransformBy(matrix1).TransformBy(matrix2); secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2); ToolComp comp = ToolComp.None; if (firstPt.X >= secondPt.X && firstPt.Y >= secondPt.Y) { comp = ToolComp.Left; } else if (firstPt.X >= secondPt.X && firstPt.Y < secondPt.Y) { comp = ToolComp.Right; } else if (firstPt.X < secondPt.X && firstPt.Y < secondPt.Y) { comp = ToolComp.Left; } else if (firstPt.X < secondPt.X && firstPt.Y >= secondPt.Y) { comp = ToolComp.Right; } List <Point3d> points = new List <Point3d>() { firstPt, secondPt }; Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = points; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); }
public override void ToMachining(double AssociatedDist, ToolFile toolFile) { //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标 //matrix1负责把所在点的坐标转换为板件中心的坐标 //matrix2负责把板件中心的坐标,再转换为MP中心的坐标 Point3d pt = Part.GetPartPointByNumber(EdgeNumber.ToString()); Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem( Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, pt, (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber), (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber), Vector3d.ZAxis); Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem( Part.MPPoint, Part.MPXAxis, Part.MPYAxis, Part.MPZAxis, Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis); if (LeadIn > 0) { double rRadius = LeadIn; Point3d firstPt = new Point3d(Radius + rRadius, -rRadius, Depth); Point3d secondPt = new Point3d(Radius, 0, Depth); Point3d thirdPt = new Point3d(0, Radius, Depth); Point3d forthPt = new Point3d(-rRadius, Radius + rRadius, Depth); firstPt = firstPt.TransformBy(matrix1).TransformBy(matrix2); secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2); thirdPt = thirdPt.TransformBy(matrix1).TransformBy(matrix2); forthPt = forthPt.TransformBy(matrix1).TransformBy(matrix2); double firstBulge = -0.414214; ToolComp comp = ToolComp.None; if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y) { comp = ToolComp.Left; firstBulge *= -1; } else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y) { comp = ToolComp.Right; } else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y) { comp = ToolComp.Left; firstBulge *= -1; } else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y) { comp = ToolComp.Right; } Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = new List <Point3d>() { firstPt, secondPt, thirdPt, forthPt }; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, firstBulge, 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); } }
public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile) { //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标 //matrix1负责把所在点的坐标转换为板件中心的坐标 //matrix2负责把板件中心的坐标,再转换为MP中心的坐标 Point3d pt = Part.GetPartPointByNumber(EdgeNumber.ToString()); Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem( Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, pt, (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber), (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber), Vector3d.ZAxis); Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem( Part.MPPoint, Part.MPXAxis, Part.MPYAxis, Part.MPZAxis, Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis); //板件如果旋转,则生成的坐标点是不一样的 List <Point3d> Points = new List <Point3d>(); Point3d firstPt = new Point3d(XDist, -LeadIn, Depth); Point3d secondPt = new Point3d(XDist, YDist, Depth); Point3d thirdPt = new Point3d(-LeadIn, YDist, Depth); firstPt = firstPt.TransformBy(matrix1).TransformBy(matrix2); secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2); thirdPt = thirdPt.TransformBy(matrix1).TransformBy(matrix2); Points.Add(new Point3d(firstPt.X, firstPt.Y, Depth)); Points.Add(new Point3d(secondPt.X, secondPt.Y, Depth)); Points.Add(new Point3d(thirdPt.X, thirdPt.Y, Depth)); //判断刀补的方向 ToolComp comp = ToolComp.None; if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y) { comp = ToolComp.Left; } else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y) { comp = ToolComp.Right; } else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y) { comp = ToolComp.Left; } else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y) { comp = ToolComp.Right; } Machinings.Routing route = new Machinings.Routing(); route.ToolName = ToolName; route.Points = Points; route.Part = Part; route.ToolComp = comp; route.Bulges = (new double[] { 0, 0, 0 }).ToList(); if (FaceNumber == 5) { route.OnFace5 = true; } else { route.OnFace5 = false; } Part.Routings.Add(route); }