Randomizing print location?
-
(interesting, keeping an eye on this)
-
I have been interested in some randomizing function for a while. I want to select gcode files at random to run on my sandtable.
-
Couldn't you just change where you want it to print by manually setting the origin to a different spot?
-
@bot, do you mean moving in the slicer? I uploaded the model once to duet and it works so my preference is to stick to this gcode file and keep printing it.
-
Are you running RRF2 or RRF3? The latter may allow you to find some pseudo random variables in the object model stuff and apply a work offset before printing?
-
@zapta I meant like, after you home your X/Y axes, you can move them to any point on the bed, and use G92 to define that point as something else. This way you can offset the print any direction arbitrarily by offsetting the coordinates.
-
Yes, easily, manually before a print.
- G10 L2 P2 Xnn Ynn ; Set the offset. nnn can be positive or negative numbers.
- G55 ; Turn on the offset by enabling Work Coordinate System 2 (the P2 in the above command)
- G54 ; Turn off the offset by going back to WCS 1
Example: If an object with a "footprint" of 50x50 was printing in the middle of a 300x300 bed, it would have about 125mm all around it.
G10 L2 P2 X-50 Y50
G55From the console. The numbers could be +/- roughly 125... but don't cut it too close...
-
@Danal, any idea how to set the x/y offset randomly for each print?
@bearer, I am using RRF2 but it's on my TODO to switch to RFF3.
-
What type of filament are you printing with? How about cleaning the bed between prints? Maybe lowering the bed temperature would do the job. I print PETG on a 45C bed. Prints stick fine while printing and come off pretty easily when the bed cools.
-
@zapta said in Randomizing print location?:
@Danal, any idea how to set the x/y offset randomly for each print?
@bearer, I am using RRF2 but it's on my TODO to switch to RFF3.
Sure.
Almost all slicers allow for an automated post-process script. Put
G10 L2 P2 Xrandom Yrandom G55
(literally random, as shown) in the start gcode (and G54 in your end gcode if you wish).
Then, invoke a post-processing script in your choice of languages that include a random function, and decent string searching.
Example Python:
import random with open('[this will vary by slicer]', 'r') as input_gcode_file: gcode = input_gcode_file.read() gcode = gcode.replace('Xnnn', 'X'+str(random.randint(-10,10))) gcode = gcode.replace('Ynnn', 'Y'+str(random.randint(-10,10))) with open('[this will vary by slicer]', 'w') as output_gcode_file: output_gcode_file.write(gcode)
It could be done in PERL, Basic, whatever. And, Python programmers who are reading this, forgive me, there are about a million other more "Python-ish" ways to do it, the above is very brute force and therefore more readable for non-Python people.
(Code is untested; should work!)
-
Post processing doesn't solve the desire to upload the file once and just keep reprinting it.
-
Absolutely true. Randomizing repeated prints that repeat in the printer will require random() in the printer. Sort of obvious when phrased that way.
Although... why repeat in the printer? Why not have the gcode sitting somewhere that you can 'push one button' or 'run one command' and the g-code is processed (random offset) again, pushed to the printer, and a print kicked off.
Lot's of ways to get things done.
-
@Danal said in Randomizing print location?:
Lot's of ways to get things done.
Yup. Another one would be to use a print surface that doesn't wear out. (I expect this will lead to a lot of incoming from the PEI fan club so I'll don my tin hat now).
-
If running RRF 3.01RC you could generate two pseudo-random numbers from the object model and those in a G10 L2 P1 command to adjust the X and Y workplace coordinate offsets.
Here are some ideas for generating pseudo-random numbers from the number of seconds that the Duet has been running:
sin(radians(state.upTime))
cos(radians(state.upTime*3))
mod(state.upTime,15)