Does this count as a build?

To lock the sand pattern, water down some Elmer’s glue in a spray bottle. Few light coats should do it.

Magnet.
http://unitednuclear.com/index.php?main_page=product_info&cPath=70_79&products_id=265

I don’t claim to know everything on the Internet, but I don’t know how that would work. There are some online Python interpreters, but I had some difficulty getting external libraries to work with them.

This is the library I was thinking of using:
http://blog.thegaragelab.com/massage-your-gcode-with-python/

It has filters already for rotating gcode. It doesn’t have a scale for some reason, but I think that would be easy to add. The arcs might be an issue, but you can avoid using arcs at first.

I guess you’re thinking that there would be a website where you could input a few key numbers, like the center of a circle, and it would return a gcode file that you could load on the SD?

Keep in mind, you don’t have to learn the whole language, you just have to get enough to do what you want.

Barry, that is pretty much what I have. I think the diameter is too much the ball jumps from the outer edge to the center as it moves. I am thinking maybe something like a cow magnet, a much smaller diameter so if it does move you won’t really see it.

Hefe, I was figuring lines are easy enough to do the math on and arcs I would just pick a value between nodes and plot them individually until I learn how to use arcs. I figured I would have to write it all from scratch. But I was just looking at something that had some shortcuts for an interface. I have zero GUI experience. Some input boxes, and maybe a few drop downs, eventually show a graphic of the output.

I can look around, there has to be something out there, or maybe a gui is easier to build than I think.

It really is (responding to the difficulty of making a GUI). And (sounding like a broken record) python has some good libraries. flask and bottle are two really simple libraries for hosting a web page from python. If you wanted this to be on the Internet, I have 0 experience there, but if you wanted something that would just run on a pi connected to your arduino, I could help. It’s really just a few lines to get started, then you can polish it as much as you want. You probably have more experience with web than I do thanks to these forums.

The hard part about GUIs is always getting them to run on someone else’s machine. Because other people have Windows, or Linux, or Mac, or Android. That’s why the web page works so well. A lot of companies (like slack) have their GUI run in a stripped down version of chrome (electron, same as the atom editor) just to make it cross platform.

I was just toying with that gctools, and I made the input gcode rotate 90 degrees in 1 degree steps:

[scode lang=“python”]
#!/usr/bin/env python

from util import *

input = loadGCode(‘input.gcode’)

start with the output just being the input

output = GCode()

for each of these angles

for angle in range(90):
# rotate the input to that angle
temp = input.clone(Rotate(angle))

# copy that rotationm to the output
output.lines += temp.lines

saveGCode(“output.gcode”, output)

[/scode]

The attached was made from this input file:

[pre]
G01 X-100.0 Y-100.0
G01 X100.0 Y-100.0
G01 X100.0 Y100.0
G01 X-100.0 Y100.0
[/pre]

Super quick. Making it scale is a little harder, and I think I’d also want it to scale each point so it’s a smooth transition from one rotation to the next. Adding a web interface is a few more lines, really. The hard part is getting a machine with gctools, PIL, and access to the web page.

output.gcode (8.49 KB)

I’ll have to look. I was just hoping to use something very similar to c++ because I have a few semesters worth of serious math programming in it, including iterative solutions with input and output. The last final I remember taking was pen and paper doing a infinite matrix by hand solving a nasty problem. Took about 35 minutes by hand for the first person to turn it in. An hour or so for the rest of us.

I do enjoy programming a little bit, so maybe it is time to learn something new.

Ya’ll are making this way too hard.

Drop gcode and drop estlcam.

just setup an arduino to randomly move the steppers to produce it’s “own” design. The machine is it’s own artist.

adding two rotators for the etch a sketch function would be easy. Simple switch to flip from manual to auto.

1 Like

Coming from C++ to Python is a joy. As Jeff says, the libraries rock. I bet you could do the same math programming you were doing with numpy and scipy with less brainpower.

There’s a turtle lib which someone has converted the output to Gcode here:

I’m pretty pleased I found this because I’m really into doing some large format plotting for fun.

https://www.google.co.uk/search?q=python+turtle&safe=off&source=lnms&tbm=isch&sa=X&ved=0ahUKEwifkcakjNzUAhXJ2hoKHV5tD4cQ_AUIBigB&biw=1280&bih=841

1 Like

James, my buddy my pal. I think you found what we are looking for! I knew something had to exist.

I just checked the code, and it’s not really doing anything special. But I think the gcodetools lib that Jeff posted is pretty interesting.

I didn’t get the reason for the web interface? Is it seen as a quick route for a GUI?

TK is the GUI toolkit you’d turn to in Python, and it’s probably as easy as writing web interfaces.

As for the libs question, Jeff, if I understand, you are talking about runtime library dependencies?

If that’s the case you can make your Python distributable with p2exe, but there are other ways too.

I can’t wait to mess around with this stuff myself. What’s great is there are tons of tutorials/examples of some quite complex plotting people have done with Python Turtle ready to be adapted to output gcode. I’d say it should be possible to make something quite slick that you can have a GUI where you could use interface controls or paste turtle commands, if that’s of interest.

Edit: Stupid question deleted

The interface would be for people to be able to make there own code. I am imagining it like the MPCNC where every single build is a different size. Having to download and run a program would be intimidating for some.

I am thinking the non cnc crowd. My close friends, the ones who are kind of oblivious to what I do, saw this and immediately took interest and got excited. These are the one I help with tech support for so I was thinking how could I make them one and let them use it without calling me everyday for help. They see this as amazing…to me it is half of a cnc machine and it is the simple half…to them it is magic.

tilt?

Sorry for skim reading about the Web GUI reasoning, I was at work.

A web GUI has one advantage in that you will find more able people to help should you share the project.

A desktop application might be easier to distribute as a simple installer, and won’t depend on a web server to run.

Also you’ll be able to easily talk to the machine via the USB/COM port of the controller board if you write a proper application.

Just speaking from my experience. Both will work fine. I’d be more than happy to lend a hand with the development, but it sounds like you’re keen yourself, and Jeff’s ahead of me in the queue :slight_smile:

No way, group effort!

I feel pretty excited about this so maybe I should focus on the hardware first. I have a bunch of stuff coming next day from amazon. Monday’s for me are catching on on shipping from the weekend, then after I get that done I will start sketching some new parts. You guys both seem way more qualified than me, but I will check out the links you put up in more detail after I get the orders out. If it clicks for me and seems easy I will give it a try.

Ah, makes more sense now, OK.

So if you’re talking about an integrated system you install for people, you would build in a raspberry PI or similar and get that to run the web interface, right?

No, that could be optional. Just output gcode onto a sd for now and run it on the lcd screen. Baby steps.

There are a few way to do fully automated.

I am thinking just an easy way to set a table size X and Y dimensions, then have some drop downs or something to play with (squares, circles, triangles, flowers, hearts whatever). If we could get to the point to add letters…would be amazing.

The hardware options are already coming to me, I think I can get this pretty simplified. I think sticking with conduit is still best for now…

Right, so now I think I finally get it.

You’re thinking of a central web page, that you would need to arrange hosting for?

This is very easy to do with a Python program, but if it is the case, then I would 100% say do it all in JavaScript as per your first suggestion.

HTML5 has SVG support, and it’s definitely not an issue to convert to Gcode in the browser. This way there is no server side component, so you can put a flat JavaScript driven page on your website. As you said, like the calculator.

I found a couple of things that would probably help you along:

This one is Node, meaning it’s written for server side, but the code will run for sure in the browser with a little migration:

Perhaps more useful:

Open source Turtle browser implementation (half way there):

See the live demo; type demo() in the command box:

https://rawgit.com/wrschneider99/js-turtle/master/turtle.html

Here is a JavaScript lib similar to the Python one Jeff posted to help with generating gcode from primitives:

https://github.com/zackaholic/Plotter/blob/master/example.js

But as we saw with the Python / Turtle script, you can very simply concatenate the Gcode on the fly directly from the vector values available.

To get the file download option when you have no server disk, you can create the file in the browser memory and use a data URI to trigger the download:

I was very confused until I looked up what turtle is:

https://docs.python.org/2/library/turtle.html

Now that I see that, I can see how that would be useful.

There’s no reason there can’t be more than one way to drive this thing. There are several ways to do anything with the MPCNC. Having a webpage just load up some client side javascript would be the best in the long term, because you don’t have to deal with installing anything, and you don’t have to sacrifice anything on the server besides the space and BW for loading the program. The python would be server side or installed on the user’s machine. AFAIK, there are no other options. I personally don’t like writing javascript, but to each their own, it’s a simple enough program that you could do it.

Here’s some brain dumping:

So if I were to narrow the scope, and come up with something that just took a pattern, scaled and rotated it until it became line art instead of just a polygon, the requirements for something like that would be:

  • The input would have to be a connected set of paths, that were completely inclosed. They could be overlapping, concave or anything like that, but they would have to be continuous, and start and end at the same place.
    • For example, a rectangle, circle (interpolated into many line segments), a triangle, or even something like the open hardware logo would work.
    • Something with two polygons wouldn’t work as expected. Like a donut, because it needs to get from one circle to the other, and it can’t lift up.
  • The output would need to be the path to take. I don’t think there is any CAM that would take the line art and correctly engrave it in the right order.
  • A “transform” would be the generic thing you can apply to the shape to make it slide around in the workspace.
    • Easy transforms are scale, rotate, and translate.
    • More complicated ones would be to follow a parametric function, like translate around a circle, while rotating, and while scaling according to a sine function.

That seems pretty doable, and simple, actually. You take the input, convert it to something that understands x, y and then perform a transform on each point, and output x, y, do it in a for loop. Then convert the output to gcode.

Gcode as input:
Making the input gcode would intimidate some people, but not others. For things like a triangle, it might be overkill, but for things like the open source hardware logo, it would be tough to do by hand. The nice thing about gcode is that it forces things to be connected, sort of. Every line segment is and x, y and the previous x, y. That doesn’t work if the gcode includes Z. Another benefit, at least for testing is that the gctools library can read it, and perform quite a few transforms.

Web as input:
If you can make a list of X,Y points from a web form, then it would work just as well as gcode. If you’re talking about having a set of radio buttons for circle, square, triangle, then it’s pretty limited. Maybe there’s also a custom button where people can paste in a TSV list of points.

Svg as input:
IMO too complicated. There are just too many things svg can do. For example which layer do you read?

Turtle as input:
Seems to be very simple. There seem to be a lot of ways to test your algorithm. Just to be clear, what I’m suggesting is something like the turtle2svg web page, but with the output being gcode. People would tell the ball to “go forward(50)” and then “turn left(45)” and they can add for loops, etc. It would be easy to make star shapes, it’s relatively simple. It would completely define what we need to do. One downside is that people might be intimidated if it feels too much like a program language.

Ggode as output:
Obviously a good choice. As I said earlier, I don’t think anything can take an SVG and do a good job writing the gcode for that, because you want it traced in a particular order.

Arduino as output:
If you wanted, you could have some other format that the arduino uses to move, and read that in. I don’t think that’s really useful. GCode is really already well hammered on for this purpose.

Python for transforms:
I like it! No one else will though. Being able to write an arbitrary python function to transform the shape is pretty advanced.

Turtle for transforms:
This is an interesting concept. I could imagine checkmarks or radio buttons for scaling, rotating, and translating and then a checkmark for turtle, where you could write turtle commands to define the parametrics of the advanced transform.

Web for transforms:
You’d be limited to the most basic options, like: Rotate CW 1 “Unit” per shape, while scaling between full size and 10%. Some simple options, like min/max scale, speed to scale, and speed to rotate would all be easy to parse. Anything more complicated would require some skills, but maybe some basic things like having a translation based on a circle, or something.

Command line for transforms:
This seems like a good way to do it to me. People who have used a raspberry pi, but not necessarily done any programming could use it. It might also be an easy way to write a GUI, because it can just interface to the CLI.

I think I can write something pretty quick to read in a gcode file and some options via command line, and then output a gcode file in python. I don’t know anything about p2exe, and I don’t have a windows machine I can test anything on, but I can make a few gcode files and share the code to make them.

I have to go, and I won’t be able to look at this for a few days, but here is a draft. It does scale, clip and rotate. Usage:

[pre]./sandify.py -h
Usage: sandify.py [options]

Options:
-h, --help show this help message and exit
-l LOOPS, --loops=LOOPS
Select how many copies of the shape you’d like
-x SIZE_X, --size_x=SIZE_X
Select the max size for the X axis.
-y SIZE_Y, --size_y=SIZE_Y
Select the max size for the Y axis.
-r ROTATE, --rotate=ROTATE
Select how many degrees to rotate for each copy of the
shape. Positive is CW, negative is CCW. Rotates the
shape around the size_x/2, size_y/2
-s SCALE, --scale=SCALE
Select how many percent to scale the shape for each
copy of the shape. Positive will grow, negative will
shrink. For example, -10 will scale from 100 to 0 in
10 steps
[/pre]
The main body of code:

[scode lang=“python”]
#!/usr/bin/env python

from util import *
import optparse
import sys
import os.path

First, define some filters used in this process

class Scale(Filter):
“”" Scale the input from 0,0
“”"

def init(self, scale):
self.scale = scale

def apply(self, command):
result = command.clone()

if command.X is not None:
  result.X = command.X * self.scale
if command.Y is not None:
  result.Y = command.Y * self.scale

return result

class Clip(Filter):
“”" Clip any commands so they do not escape the desired size
“”"

def init(self, size_x, size_y):
self.size_x = size_x
self.size_y = size_y

def apply(self, command):
result = command.clone()

if command.X is not None:
  result.X = min(max(command.X, 0.0), self.size_x)
if command.Y is not None:
  result.Y = min(max(command.Y, 0.0), self.size_y)

return result

consume the command line arguments first. Details: https://docs.python.org/2/library/optparse.html

parser = optparse.OptionParser(usage=“usage: sandify.py [options] <input.gcode>”)
parser.add_option(’-l’, ‘–loops’, dest=‘loops’, default=10,
help=“Select how many copies of the shape you’d like”)
parser.add_option(’-x’, ‘–size_x’, dest=‘size_x’, default=100,
help=“Select the max size for the X axis.”)
parser.add_option(’-y’, ‘–size_y’, dest=‘size_y’, default=100,
help=“Select the max size for the Y axis.”)
parser.add_option(’-r’, ‘–rotate’, dest=‘rotate’,
help=“Select how many degrees to rotate for each copy of the shape. Positive is CW, negative is CCW. Rotates the shape around the size_x/2, size_y/2”)
parser.add_option(’-s’, ‘–scale’, dest=‘scale’,
help=“Select how many percent to scale the shape for each copy of the shape. Positive will grow, negative will shrink. For example, -10 will scale from 100 to 0 in 10 steps”)
(options, input_gcode) = parser.parse_args()

clean up some of these options

options.loops = int(options.loops)
print ‘Configured to run for {} loops’.format(options.loops)
options.size_x = float(options.size_x)
options.size_y = float(options.size_y)
print ‘Configured to limit the size between (0,0) and ({},{})’.format(options.size_x, options.size_y)
if options.rotate:
options.rotate = float(options.rotate)
if options.scale:
options.scale = float(options.scale)

check for an input file

if not input_gcode or len(input_gcode) != 1 or not os.path.isfile(input_gcode[0]):
print(‘ERROR, you need to specify a gcode file as input’)
sys.exit(1)

print ‘Reading in {}’.format(input_gcode[0])

input = loadGCode(input_gcode[0])

Start with a clean slate of gcode

output = GCode()

print ‘Performing transformations’

for each of these angles

for loop in range(options.loops):
# rotate the input to that angle
loop_shape = input.clone()

if options.rotate:
    loop_shape = loop_shape.clone(Translate(-options.size_x/2, -options.size_y/2),
                                  Rotate(options.rotate * loop),
                                  Translate(options.size_x/2.0, options.size_y/2.0))

if options.scale:
    loop_shape = loop_shape.clone(Translate(-options.size_x/2, -options.size_y/2),
                                  Scale((1.0 + (0.01 * options.scale * loop))),
                                  Translate(options.size_x/2.0, options.size_y/2.0))

# Clip
loop_shape = loop_shape.clone(Clip(options.size_x, options.size_y))

# copy that rotationm to the output
output.lines += loop_shape.lines

output_name = ‘output.gcode’
print ‘Saving output gcode to {}’.format(output_name)
saveGCode(output_name, output)

[/scode]

Example output:
[pre]
./sandify.py input.gcode -l6 -s -4 -r 5 && cat output.gcode
Configured to run for 6 loops
Configured to limit the size between (0,0) and (100.0,100.0)
Reading in input.gcode
Performing transformations
Saving output gcode to output.gcode

G01 X20.0000 Y20.0000
G01 X80.0000 Y20.0000
G01 X80.0000 Y80.0000
G01 X20.0000 Y80.0000

G01 X23.8197 Y18.7995
G01 X81.2005 Y23.8197
G01 X76.1803 Y81.2005
G01 X18.7995 Y76.1803

G01 X27.6120 Y18.0266
G01 X81.9734 Y27.6120
G01 X72.3880 Y81.9734
G01 X18.0266 Y72.3880

G01 X31.3324 Y17.6667
G01 X82.3333 Y31.3324
G01 X68.6676 Y82.3333
G01 X17.6667 Y68.6676

G01 X34.9387 Y17.7008
G01 X82.2992 Y34.9387
G01 X65.0613 Y82.2992
G01 X17.7008 Y65.0613

G01 X38.3915 Y18.1058
G01 X81.8942 Y38.3915
G01 X61.6085 Y81.8942
G01 X18.1058 Y61.6085

[/pre]

That should get you started with some prettier pictures, Ryan.

sandify.zip (60 KB)