Exemple #1
0
        public void SetTool(int toolNo, int frequency, double angleA = 0, bool hasTool = true)
        {
            StopEngine();
            ToolLocation.Set(new Point3d(double.NaN, double.NaN, ZSafety + UpperZ), 0, 0);
            SetToolCommands(toolNo, angleA);

            _frequency = frequency;
            _hasTool   = hasTool;
        }
Exemple #2
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 (point == null)
            {
                point = new Point3d(x ?? ToolLocation.Point.X, y ?? ToolLocation.Point.Y, z ?? ToolLocation.Point.Z);
            }

            if (ThickCommand != null && (point.Value.X != ToolLocation.Point.X || point.Value.Y != ToolLocation.Point.Y))
            {
                _commands.Add(
                    new ProcessCommand
                {
                    Text         = string.Format(ThickCommand, point.Value.X.Round(), point.Value.Y.Round()),
                    HasTool      = _hasTool,
                    ToolLocation = ToolLocation.Clone()
                });
            }

            command.Text = GCommandText(gCode, paramsString, point.Value, curve, angleC, angleA, feed, center);

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

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

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

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

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

            _commands.Add(command);
        }