Package: wheecode
Wheecode`GCode for allWheecode is a fork ofmecode, designed to simplify GCode generation.  It
is not a slicer, thus it can not convert CAD models to 3D printer ready code.
It simply provides a convenient, human-readable layer just above GCode. If you
often find yourself manually writing your own GCode, then wheecode is for you.Basic UseTo use, simply instantiate theGobject and use its methods to trace your
desired tool path.fromwheecodeimportGg=G()g.move(10,10)# move 10mm in x and 10mm in yg.arc(x=10,y=5,radius=20,direction='CCW')# counterclockwise arc with a radius of 20g.meander(5,10,spacing=1)# trace a rectangle meander with 1mm spacing between passesg.abs_move(x=1,y=1)# move the tool head to position (1, 1)g.home()# move the tool head to the origin (0, 0)By defaultwheecodesimply prints the generated GCode to stdout. If instead you
want to generate a file, you can pass a filename when
instantiating theGobject.g=G(outfile='path/to/file.gcode')NOTE:When using the option direct_write=True or when writing to a file,g.teardown()must be called after all commands are executed. If you
are writing to a file, this can be accomplished automatically by using G as
a context manager like so:withG(outfile='file.gcode')asg:g.move(10)When thewithblock is exited,g.teardown()will be automatically called.The resulting toolpath can be visualized in 3D using themayaviormatplotlibpackage with theview()method:g=G()g.meander(10,10,1)g.view()The graphics backend can be specified when calling theview()method, e.g.g.view('mayavi').Direct control via serial communicationWith the optiondirect_write=True, a serial connection to the controlled device
is established via USB serial at a virtual COM port of the computer and the
g-code commands are sent directly to the connected device using a serial
communication protocol:importwheecodeg=wheecode.G(direct_write=True,direct_write_mode="serial",printer_port="/dev/tty.usbmodem1411",baudrate=115200)# Under MS Windows, use printer_port="COMx" where x has to be replaced by the port number of the virtual COM port the device is connected to according to the device manager.g.write("M302 S0")# send g-Code. Here: allow cold extrusion. Danger: Make sure extruder is clean without filament insertedg.absolute()# Absolute positioning modeg.move(x=10,y=10,z=10,F=500)# move 10mm in x and 10mm in y and 10mm in z at a feedrate of 500 mm/ming.retract(10)# Move extruder motorg.write("M400")# IMPORTANT! wait until execution of all commands is finishedg.teardown()# Disconnect (close serial connection)All GCode MethodsAll methods have detailed docstrings and examples.set_home()reset_home()feed()dwell()home()move()abs_move()arc()abs_arc()rect()meander()clip()triangular_wave()Matrix TransformsA wrapper class,GMatrixwill run all move and arc commands through a
2D transformation matrix before forwarding them toG.To use, simply instantiate aGMatrixobject instead of aGobject:g=GMatrix()g.push_matrix()# save the current transformation matrix on the stack.g.rotate(math.pi/2)# rotate our transformation matrix by 90 degrees.g.move(0,1)# same as moves (1,0) before the rotate.g.pop_matrix()# revert to the prior transformation matrix.The transformation matrix is 2D instead of 3D to simplify arc support.Renaming AxesWhen working with a machine that has more than one Z-Axis, it is
useful to use therename_axis()function. Using this function your
code can always refer to the vertical axis as 'Z', but you can dynamically
rename it.InstallationThe easiest method to install wheecode is with pip:pipinstallwheecodeTo install from source:$gitclonehttps://github.com/xloem/wheecode.git
$cdwheecode
$pipinstall-rrequirements.txt
$pythonsetup.pyinstallOptional DependenciesThe following dependencies are optional, and are only needed for
visualization. An easy way to install them is to useconda.numpymatplotlibvpythonmayaviTODOadd pressure box comport to__init__()methodbuild out multi-nozzle supportinclude multi-nozzle support in view method.factor out aerotech specific methods into their own classauto set MFO=100% before each printadd ability to read current status of aerotechturn off omnicure after aborted runsadd formal sphinx documentationcreate github pageCreditsThis software was originally developed by theLewis Labat Harvard University, likely by Jack Minardi, and then forked and added on to by many people and organizations listed in the commit history.