Could someone help me with repeating code? Maybe it is called "block" code?

Could someone help me with repeating code? Maybe it is called “block” code?
I have a cut (think scraper/shaver) that I need to progressively go deeper. Can I do this with chilipeppr and TinyG? What command is used for that?

Do you use a cam program or are you doing it manually? You could probably write a macro to do it. I never have before but I use cam bam to program all my work

I’m generating the G-Code with Inkscape add-on G-Code tools.
It gives me the curve g-code and I need to find a way to repeat it progressively at .005 advances. I’ll look up Cam Bam.

I see cam bam is Windows only. I’m trying to get all this done on a Mac.

Can I call a subroutine with chilipeppr and TinyG?

Look at the macros in ChiliPeppr. This would be a super easy for loop with the Gcode where you generate each line at lower z’s and then send the final gcode to your workspace. The zig zag macro is a good one to look at as a starting point.

I see where the for loop of XY Gcode command would do what I need. Implementing it however looks challenging. I have some C++ knowledge but were definitely beyond that here! I’ve pasted the code into a text editor so I can look it over but just don’t see where I can modify it to run my block of XY curve dropping down .005 on the Z each pass.

Here’s some high level code ideas for the ChiliPeppr macro.

var lines = [];
var s = “(your xy curve gcode here)”;

// start at z 0, move down .005 each loop, end at -10
for (var z = 0; z > -10; z = z - 0.005) {
lines.push(“G1 Z” + z);
lines.push(s);
}

var newgcode = lines.join("\n"); // convert array to string with newlines at end of each gcode line

// publish gcode to workspace
var info = {
name: “My gcode file”,
lastModified: new Date()
};
// send event off as if the file was drag/dropped
chilipeppr.publish("/com-chilipeppr-elem-dragdrop/ondropped", newgcode , info);

I’ve incorporated the code above into my G-code file but can not get multiple passes.

var lines = []; <<should there be something here?
var s = “about 200 lines”; <<I have curve between the" "

// start at z 0, move down .005 each loop, end at -10
for (var z = 0; z > -10; z = z - 0.005) {
lines.push(“G1 Z” + z); <<should there be something here?
lines.push(s); << is (s) a variable?
}

var newgcode = lines.join("\n"); // convert array to string with newlines at end of each gcode line

// publish gcode to workspace
var info = {
name: “My gcode file”,
lastModified: new Date()
};
// send event off as if the file was drag/dropped
chilipeppr.publish("/com-chilipeppr-elem-dragdrop/ondropped", newgcode , info);

Thanks Tom

No, you have to use the Macro widget to run this. This is not Gcode, this is Javascript.

Tomorrow I’ll try to read up on JavaScript enough to understand.

@jlauer any chance of that being in the next version as something that can be turned on/off?

@NathanielStenzel you mean like a widget that has you cut/paste Gcode in it that represents XY moves, and then you can generate the Z moves to go up or down the distance you specify? If so, that does sound cool, but it may be something that won’t get used because nobody can understand it. My gut tells me once you’re in that zone of needing something like that, it’s specific enough of a problem, that perhaps only a macro can solve it for you. Not sure though.

My solution until now has been to run the head home, change the Z and then chew through the curve section of code again. Now that I’m moving into nearly full length stretches of curve description consisting of hundreds of lines the browser chokes.

@Tom_Matthews have you gotten anywhere on the macro? I could help you further on it if you’re stuck.

I think I might have the idea but until I’m off work I won’t have much time to try things. For now, I’m reading up. Any suggestions?
So far it seems quite like C++. Somehow I’ll get it!

Will you post the Gcode you’re trying to repeat?

Here is a short version.

G03 X1.243861 Y0.943424 I0.274342 J0.713764 F400.000000
G03 X1.511497 Y0.988931 I0.007674 J0.764633
G03 X1.620110 Y1.035271 I-0.356181 J0.985294
G02 X1.727453 Y1.084826 I0.966181 J-1.951830
G02 X1.839290 Y1.123891 I0.337331 J-0.786098
G02 X1.955897 Y1.137321 I0.102112 J-0.373664
G02 X2.072658 Y1.115232 I-0.014923 J-0.398523
G02 X2.183937 Y1.070226 I-0.414609 J-1.185206
G03 X2.293013 Y1.020430 I6.459942 J14.006008
G03 X2.406256 Y0.983121 I0.231758 J0.512928
G03 X2.526591 Y0.973625 I0.095552 J0.443628
G03 X2.645173 Y0.996189 I-0.024783 J0.453123
G03 X2.753611 Y1.049216 I-0.143365 J0.430560
G03 X2.844233 Y1.128956 I-0.251803 J0.377532
G03 X2.958961 Y1.042343 I0.388003 J0.394662
G03 X3.092125 Y0.988199 I0.273274 J0.481272
G03 X3.234741 Y0.970176 I0.140110 J0.535417
G03 X3.377188 Y0.989490 I-0.002507 J0.553439
G03 X3.487717 Y1.029632 I-0.184931 J0.681435
G02 X3.595315 Y1.078068 I2.819723 J-6.120193
G02 X3.705951 Y1.119582 I0.430603 J-0.979388
G02 X3.821588 Y1.137880 I0.119703 J-0.381931
G02 X3.939508 Y1.121194 I0.004029 J-0.396542
G02 X4.052251 Y1.079461 I-0.273212 J-0.911240
G02 X4.161007 Y1.028729 I-1.300385 J-2.929597
G03 X4.271948 Y0.983680 I0.379155 J0.774612
G03 X4.491520 Y0.951399 I0.203659 J0.622379
G03 X4.709265 Y0.994310 I-0.015913 J0.654661
G03 X4.975066 Y0.943270 I0.274245 J0.710556
G03 X5.241934 Y0.988404 I0.008444 J0.761597
G03 X5.350564 Y1.034695 I-0.353753 J0.980756
G02 X5.457906 Y1.084248 I0.971042 J-1.962454
G02 X5.569733 Y1.123336 I0.337824 J-0.786965
G02 X5.686334 Y1.136794 I0.102188 J-0.373513
G02 X5.803098 Y1.114720 I-0.014836 J-0.398330
G02 X5.914378 Y1.069715 I-0.414179 J-1.184176
G03 X6.023452 Y1.019913 I6.502756 J14.097626
G03 X6.136693 Y0.982594 I0.231786 J0.512877
G03 X6.257029 Y0.973092 I0.095571 J0.443572
G03 X6.375612 Y0.995654 I-0.024765 J0.453070
G03 X6.484051 Y1.048684 I-0.143349 J0.430512
G03 X6.574669 Y1.128429 I-0.251786 J0.377479
G03 X6.689398 Y1.041817 I0.388003 J0.394667
G03 X6.822562 Y0.987673 I0.273276 J0.481281
G03 X6.965178 Y0.969650 I0.140111 J0.535421
G03 X7.107625 Y0.988963 I-0.002505 J0.553449
G03 X7.218154 Y1.029104 I-0.184926 J0.681438
G02 X7.325752 Y1.077539 I2.820290 J-6.121547
G02 X7.436388 Y1.119053 I0.430633 J-0.979465
G02 X7.552025 Y1.137353 I0.119711 J-0.381949
G02 X7.669945 Y1.120670 I0.004035 J-0.396566
G02 X7.782689 Y1.078939 I-0.273144 J-0.911116
G02 X7.891445 Y1.028207 I-1.299355 J-2.927379
G03 X8.002384 Y0.983153 I0.379320 J0.774917
G03 X8.222825 Y0.950866 I0.203771 J0.622572
G03 X8.441337 Y0.994327 I-0.016669 J0.654861

And how far will you go down on the Z axis using that 0.005mm step down?

That is Inches. So, 5 thou.