public ToolpathEnumerator(IToolpath collection) { this.collection = collection; curIndex = -1; curItem = default; }
/// <summary> /// Command toolpaths are used to pass special commands/etc to compiler. /// These toolpaths do not affect the current extruder position/etc. /// </summary> protected virtual bool IsCommandToolpath(IToolpath toolpath) { return(toolpath.Type == ToolpathTypes.Custom || toolpath.Type == ToolpathTypes.CustomAssemblerCommands); }
public void CNCparser_toolpathIsEmpty_ToolPathIsNotNull() { string inputPath = ""; var cncfp = new CNCFileParser(); IToolpath toolpath = cncfp.CreatePath(inputPath); }
public static IToolpath AddExtruderCommands(IToolpath toolpath, double externalFactor, string indMechanism = null) { if (toolpath == null) { return(toolpath); } var resetCommand = ResetCommand(toolpath.Targets.First()); var outTargets = SetExternalWithVariable(toolpath.Targets); return(toolpath.ShallowClone(outTargets)); Command ResetCommand(Target refTarget) { string declaration = $@"VAR num motorValue:= 0; PERS num extrusionFactor:= {externalFactor:0.000}; VAR robtarget current; "; string resetCode = $@"current:= CRobT(\Tool:= {refTarget.Tool.Name} \WObj:= {refTarget.Frame.Name}); EOffsSet current.extax; motorValue:= 0;"; string initCode; if (indMechanism != null) { string indCode = $@"IndReset {indMechanism},1 \RefNum:=0 \Short;"; initCode = $"{indCode}\r\n{resetCode}"; } else { initCode = resetCode; } var command = new Robots.Commands.Custom("ResetExtruder", declaration: declaration, command: initCode); command.RunBefore = true; return(command); } List <Target> SetExternalWithVariable(IEnumerable <Target> inTargets) { var outTargets = new List <Target>(); double totalDistance = 0; int count = 0; int i = 0; Target prev = null; foreach (var target in inTargets) { var current = target.ShallowClone(); double externalDistance = 0; if (target.External.Length > 0) { externalDistance = target.External[0]; } totalDistance += externalDistance; current.External = new[] { totalDistance }; current.ExternalCustom = new[] { "motorValue" }; if (i == 0) { current.AppendCommand(resetCommand); } if (externalDistance != 0) { //if (!IsExtrusion(prev)) string sign = externalDistance < 0 ? "+" : "-"; string code = $"motorValue:=motorValue{sign}{Abs(externalDistance):0.000}*extrusionFactor;"; var externalCommand = new Robots.Commands.Custom($"SetExternal{count++}", command: code); externalCommand.RunBefore = true; current.AppendCommand(externalCommand); } outTargets.Add(current); prev = target; i++; } return(outTargets); } }
public void CNCparser_toolpathIsNull_throwsException() { string inputPath = null; var cncfp = new CNCFileParser(); IToolpath toolpath = cncfp.CreatePath(inputPath); }