Skip to content

Commit

Permalink
Finished python CLI and added notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Paul committed Dec 12, 2017
1 parent 0f26ec3 commit efddca5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
23 changes: 23 additions & 0 deletions notes.md
Expand Up @@ -66,3 +66,26 @@ Visicut + inkscape for lasercutting
IGNORE THE DATASHEET!

Red-Black and Green-Blue are the coil pairs.

# Running Demo

Example:
python svgParser.py method-draw-image.svg 0 0 100 100

call python on our script with the arguments:
* image to draw
* minimum x value
* minimum y value
* maximum x value
* maximum y value

This will change the cpp main file to have the path that will draw what you want. Theoreticall, flashing that code will draw what you want where you want.


## To get your SVG ready for plotting:
Load your SVG in Method Draw http://editor.method.ac (File > Open Image)
Ungroup your elements (Object > Ungroup elements) you might have to do this more than once.
Select your path
Reorient the path (Object > Reorient Paths).
Save your image (File > Save Image) If it appears in a new window you can right click and "Save Image as..."

11 changes: 8 additions & 3 deletions svgParser.py
Expand Up @@ -9,9 +9,16 @@

parser = argparse.ArgumentParser(description='Take a file and scale.')
parser.add_argument('filename')
parser.add_argument('minx', type=int)
parser.add_argument('miny', type=int)
parser.add_argument('maxx', type=int)
parser.add_argument('maxy', type=int)
args = parser.parse_args()

outBox = [args.minx,args.miny, args.maxx, args.maxy]

# Use the second solution on this stack overflow post to guarandtee better results
# https://stackoverflow.com/questions/13329125/removing-transforms-in-svg-files

poesvg = open(args.filename, 'r')

Expand All @@ -24,11 +31,10 @@
in doc.getElementsByTagName('rect')]

doc.unlink()
# print(viewBox) # maps to 0 0 100 100 on our coordinates
svgWidth = int(''.join(list(filter(str.isdigit, svgWidth[0]))))
svgHeight = int(''.join(list(filter(str.isdigit, svgHeight[0]))))
viewBox=[0,0,svgWidth, svgHeight]
outBox = [0,0,100,100]

stringToReturn = ""
stringToReturn += "//PYTHONSTARTFLAG \n"

Expand All @@ -54,7 +60,6 @@ def pointScale(svgBox, outBox, point):
stringToReturn += ('\n')

stringToReturn +="//PYTHONENDFLAG"
# print(stringToReturn)

with open('src/main.cpp') as f:
cppData = f.read()
Expand Down

0 comments on commit efddca5

Please sign in to comment.