Beispiel #1
0
        /// <summary>
        /// Остановка станка
        /// </summary>
        //protected abstract void StopMachineCommands();
        public void SetTool(int toolNo, int frequency, double angleA = 0, bool hasTool = true, double angleC = 0, int originCellNumber = 10)
        {
            StopEngine();
            ToolPosition.Set(new Point3d(double.NaN, double.NaN, ZSafety + UpperZ), 0, 0);
            SetToolCommands(toolNo, angleA, angleC, originCellNumber);

            _frequency = frequency;
            _hasTool   = hasTool;
        }
Beispiel #2
0
 public void Command(string text, string name = null, double duration = 0)
 {
     AddCommand(new ProcessCommand
     {
         Name         = name,
         Text         = text,
         HasTool      = _hasTool,
         ToolLocation = ToolPosition?.Clone(),
         Duration     = duration
     });
 }
Beispiel #3
0
        public static void RegenToolObject(Tool tool, bool hasTool, ToolPosition location, bool isFrontPlaneZero)
        {
            ToolObject.SetToolPosition(tool, location);
            Editor.UpdateScreen();

            //if (ToolObject != null && location.IsDefined)
            //    DeleteToolObject();
            //if (ToolObject == null && location.IsDefined)
            //    ToolObject = ToolObject.CreateToolObject();
            //if (ToolObject != null)
            //    DrawToolObject(tool, location);
        }
Beispiel #4
0
        public override Matrix3d GetTransformMatrixFrom(ToolPosition toolPosition)
        {
            var millPosition = (MillToolPosition)toolPosition ?? new MillToolPosition();
            var mat1         = Matrix3d.Displacement(millPosition.Point.GetVectorTo(Point));
            var mat2         = Matrix3d.Rotation(Graph.ToRad(millPosition.AngleC - AngleC), Vector3d.ZAxis, Point);
            var mat3         = Matrix3d.Rotation(Graph.ToRad(AngleA - millPosition.AngleA), Vector3d.XAxis.RotateBy(Graph.ToRad(-AngleC), Vector3d.ZAxis), Point);

            //var mat1 = Matrix3d.Displacement(Point.GetVectorTo(millPosition.Point));
            //var mat2 = Matrix3d.Rotation(Graph.ToRad(AngleC - millPosition.AngleC), Vector3d.ZAxis, millPosition.Point);
            //var mat3 = Matrix3d.Rotation(Graph.ToRad(millPosition.AngleA - AngleA), Vector3d.XAxis.RotateBy(Graph.ToRad(-millPosition.AngleC), Vector3d.ZAxis), millPosition.Point);

            return(mat3 * mat2 * mat1);
        }
Beispiel #5
0
        public override Matrix3d GetTransformMatrixFrom(ToolPosition toolPosition)
        {
            //    //var mat1 = Matrix3d.Rotation(-AngleA.ToRad(), Vector3d.ZAxis, Center);
            //    //var mat2 = Matrix3d.Displacement(Point.GetVectorTo(newToolPosition.Point));
            //    //var mat3 = Matrix3d.Rotation(newToolPosition.AngleA.ToRad(), Vector3d.ZAxis, newToolPosition.Center);

            //    //return mat3 * mat2 * mat1;

            //    var mat1 = Matrix3d.Displacement(Point.GetAsVector());
            //    var mat2 = Matrix3d.Rotation(AngleA, Vector3d.ZAxis, Center);
            //    return mat2 * mat1;
            return(new Matrix3d());
        }
Beispiel #6
0
 public void DeleteCurves()
 {
     if (Curves == null)
     {
         return;
     }
     using (var doclock = Application.DocumentManager.MdiActiveDocument.LockDocument())
         using (Transaction tr = Acad.Database.TransactionManager.StartTransaction())
             foreach (var item in Curves)
             {
                 TransientManager.CurrentTransientManager.EraseTransient(item, new IntegerCollection());
                 item.Dispose();
             }
     Curves        = null;
     _tool         = null;
     _toolPosition = null;
 }
Beispiel #7
0
        public void SetToolPosition(Tool tool, ToolPosition toolPosition)
        {
            if (Curves != null && (toolPosition == null || tool != _tool))
            {
                DeleteCurves();
            }
            _tool = tool;
            if (toolPosition != null)
            {
                if (Curves == null)
                {
                    CreateCurves();
                }

                var matrix = toolPosition.GetTransformMatrixFrom(_toolPosition);
                //var matrix = toolPosition.Matrix;
                //if (_toolPosition != null)
                //    matrix = matrix * _toolPosition.InvMatrix;
                TransformCurves(matrix);
            }
            _toolPosition = toolPosition;
        }
Beispiel #8
0
        public void GCommand(string name, int gCode, string paramsString = null, Point3d?point = null, double?x = null, double?y = null, double?z = null,
                             double?angleC = null, double?angleA = null, Curve curve = null, int?feed = null, Point2d?center = null)
        {
            var command = new ProcessCommand {
                Name = name
            };

            if (Matrix.HasValue && point.HasValue)
            {
                point = point.Value.TransformBy(Matrix.Value);
            }

            if (point == null)
            {
                point = new Point3d(x ?? ToolPosition.Point.X, y ?? ToolPosition.Point.Y, z ?? ToolPosition.Point.Z);
            }

            if (ThickCommand != null && (point.Value.X != ToolPosition.Point.X || point.Value.Y != ToolPosition.Point.Y))
            {
                AddCommand(
                    new ProcessCommand
                {
                    Text         = string.Format(ThickCommand, point.Value.X.Round(), point.Value.Y.Round()),
                    HasTool      = _hasTool,
                    ToolLocation = ToolPosition.Clone()
                });
            }
            command.Text = GCommandText(gCode, paramsString, point.Value, curve, angleC, angleA, feed, center);

            if (ToolPosition.IsDefined)
            {
                if (curve == null && ToolPosition.Point.DistanceTo(point.Value) > 1)
                {
                    curve = NoDraw.Line(ToolPosition.Point, point.Value);
                }

                double length = 0;
                if (curve != null && curve.IsNewObject)
                {
                    if (Colors.ContainsKey(name))
                    {
                        curve.Color = Colors[name];
                    }
                    curve.LayerId = _layerId;
                    curve.Visible = false;
                    _currentSpace.AppendEntity(curve);
                    _transaction.AddNewlyCreatedDBObject(curve, true);
                    length = curve.Length();
                }
                command.ToolpathObjectId = curve?.ObjectId;

                if ((feed ?? _feed) != 0)
                {
                    command.Duration = (curve != null ? length : ToolPosition.Point.DistanceTo(point.Value)) / (gCode == 0 ? 10000 : feed ?? _feed) * 60;
                }
            }

            _GCode = gCode;
            ToolPosition.Set(point.Value, angleC, angleA);
            _feed = feed ?? _feed;

            command.HasTool      = _hasTool;
            command.ToolLocation = ToolPosition.Clone();

            AddCommand(command);
        }
Beispiel #9
0
        //public Point3d Center { get; set; } = new Point3d(double.NaN, double.NaN, double.NaN);
        //public double AngleC { get; set; }
        //public double AngleA { get; set; }



        //public bool IsDefined => !double.IsNaN(Point.X) && !double.IsNaN(Point.Y) && !double.IsNaN(Point.Z);

        public abstract Matrix3d GetTransformMatrixFrom(ToolPosition toolPosition);