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 }); }
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); }