Welcome to FlatCAM’s documentation!

Contents:

class FlatCAM.App

The main application class. The constructor starts the GUI.

adjust_axes(xmin, ymin, xmax, ymax)

Adjusts axes of all plots while maintaining the use of the whole canvas and an aspect ratio to 1:1 between x and y axes. The parameters are an original request that will be modified to fit these restrictions.

Parameters:
  • xmin (float) – Requested minimum value for the X axis.
  • ymin (float) – Requested minimum value for the Y axis.
  • xmax (float) – Requested maximum value for the X axis.
  • ymax (float) – Requested maximum value for the Y axis.
Returns:

None

build_list()

Clears and re-populates the list of objects in currently in the project.

Returns:None
clear_plots()

Clears self.axes and self.figure.

Returns:None
file_chooser_action(on_success)

Opens the file chooser and runs on_success on a separate thread upon completion of valid file choice.

Parameters:on_success (func) – A function to run upon completion of a valid file selection. Takes 2 parameters: The app instance and the filename. Note that it is run on a separate thread, therefore it must take the appropriate precautions when accessing shared resources.
Returns:None
file_chooser_save_action(on_success)

Opens the file chooser and runs on_success upon completion of valid file choice.

Parameters:on_success – A function to run upon selection of a filename. Takes 2 parameters: The instance of the application (App) and the chosen filename. This gets run immediately in the same thread.
Returns:None
get_current()

Returns the currently selected FlatCAMObj in the application.

Returns:Currently selected FlatCAMObj in the application.
Return type:FlatCAMObj or None
get_eval(widget_name)

Runs eval() on the on the text entry of name ‘widget_name’ and returns the results.

Parameters:widget_name (str) – Name of Gtk.Entry
Returns:Depends on contents of the entry text.
get_radio_value(radio_set)

Returns the radio_set[key] of the radiobutton whose name is key is active.

Parameters:radio_set (dict) – A dictionary containing widget_name: value pairs.
Returns:radio_set[key]
info(text)

Show text on the status bar.

Parameters:text (str) – Text to display.
Returns:None
load_defaults()

Loads the aplication’s default settings from defaults.json into self.defaults.

Returns:None
new_object(kind, name, initialize)

Creates a new specalized FlatCAMObj and attaches it to the application, this is, updates the GUI accordingly, any other records and plots it.

Parameters:
  • kind (str) – The kind of object to create. One of ‘gerber’, ‘excellon’, ‘cncjob’ and ‘geometry’.
  • name (str) – Name for the object.
  • initialize (function) – Function to run after creation of the object but before it is attached to the application. The function is called with 2 parameters: the new object and the App instance.
Returns:

None

Return type:

None

on_about(widget)

Opens the ‘About’ dialog box.

Parameters:widget – Ignored.
Returns:None
on_activate_name(entry)

Hitting ‘Enter’ after changing the name of an item updates the item dictionary and re-builds the item list.

Parameters:entry – The widget from which this was called.
Returns:None
on_canvas_configure(widget, event)

Called whenever the canvas changes size. The axes are updated such as to use the whole canvas.

Parameters:
  • widget – Ignored.
  • event – Ignored.
Returns:

None

on_cb_plot_toggled(widget)

Callback for toggling the “Plot” checkbox. Re-plots.

Parameters:widget – Ignored.
Returns:None
on_clear_plots(widget)

Callback for toolbar button. Clears all plots.

Parameters:widget – The widget from which this was called.
Returns:None
on_click_over_plot(event)

Callback for the mouse click event over the plot. This event is generated by the Matplotlib backend and has been registered in self.__init__(). For details, see: http://matplotlib.org/users/event_handling.html

Default actions are:

  • Copy coordinates to clipboard. Ex.: (65.5473, -13.2679)
Parameters:event – Contains information about the event, like which button was clicked, the pixel coordinates and the axes coordinates.
Returns:None
on_closewindow(param)

Callback for closing the main window.

Parameters:param – Whatever is passed by the event. Ignore.
Returns:None
on_cncjob_exportgcode(widget)

Called from button on CNCjob form to save the G-Code from the object.

Parameters:widget – The widget from which this was called.
Returns:None
on_create_aligndrill(widget)

Creates alignment holes Excellon object. Creates mirror duplicates of the specified holes around the specified axis.

Parameters:widget – Ignored.
Returns:None
on_create_mirror(widget)

Creates a mirror image of a Gerber object to be used as a bottom copper layer.

Parameters:widget – Ignored.
Returns:None
on_delete(widget)

Delete the currently selected FlatCAMObj.

Parameters:widget – The widget from which this was called.
Returns:None
on_entry_eval_activate(widget)

Called when an entry is activated (eg. by hitting enter) if set to do so. Its text is eval()’d and set to the returned value. The current object is updated.

Parameters:widget
Returns:
on_eval_update(widget)

Modifies the content of a Gtk.Entry by running eval() on its contents and puting it back as a string.

Parameters:widget – The widget from which this was called.
Returns:None
on_excellon_tool_choose(widget)

Callback for button on Excellon form to open up a window for selecting tools.

Parameters:widget – The widget from which this was called.
Returns:None
on_file_new(param)

Callback for menu item File->New. Returns the application to its startup state.

Parameters:param – Whatever is passed by the event. Ignore.
Returns:None
on_file_openproject(param)

Callback for menu item File->Open Project. Opens a file chooser and calls self.open_project() after successful selection of a filename.

Parameters:param – Ignored.
Returns:None
on_file_savedefaults(param)

Callback for menu item File->Save Defaults. Saves application default options self.defaults to defaults.json.

Parameters:param – Ignored.
Returns:None
on_file_saveproject(param)

Callback for menu item File->Save Project. Saves the project to self.project_filename or calls self.on_file_saveprojectas() if set to None. The project is saved by calling self.save_project().

Parameters:param – Ignored.
Returns:None
on_file_saveprojectas(param)

Callback for menu item File->Save Project As... Opens a file chooser and saves the project to the given file via self.save_project().

Parameters:param – Ignored.
Returns:None
on_file_saveprojectcopy(param)

Callback for menu item File->Save Project Copy... Opens a file chooser and saves the project to the given file via self.save_project. It does not update self.project_filename so subsequent save requests are done on the previous known filename.

Parameters:param – Ignore.
Returns:None
on_fileopenexcellon(param)

Callback for menu item File->Open Excellon. Defines a function that is then passed to self.file_chooser_action(). It requests the creation of a FlatCAMExcellon object and updates the progress bar throughout the process.

Parameters:param – Ignore
Returns:None
on_fileopengcode(param)

Callback for menu item File->Open G-Code. Defines a function that is then passed to self.file_chooser_action(). It requests the creation of a FlatCAMCNCjob object and updates the progress bar throughout the process.

Parameters:param – Ignore
Returns:None
on_fileopengerber(param)

Callback for menu item File->Open Gerber. Defines a function that is then passed to self.file_chooser_action(). It requests the creation of a FlatCAMGerber object and updates the progress bar throughout the process.

Parameters:param – Ignore
Returns:None
on_filequit(param)

Callback for menu item File->Quit. Closes the application.

Parameters:param – Whatever is passed by the event. Ignore.
Returns:None
on_generate_cncjob(widget)

Callback for button on geometry form to generate CNC job.

Parameters:widget – The widget from which this was called.
Returns:None
on_generate_excellon_cncjob(widget)

Callback for button active/click on Excellon form to create a CNC Job for the Excellon file.

Parameters:widget – Ignored
Returns:None
on_generate_gerber_bounding_box(widget)

Callback for request from the Gerber form to generate a bounding box for the geometry in the object. Creates a FlatCAMGeometry with the bounding box. The box can have rounded corners if specified in the form.

Parameters:widget – Ignored.
Returns:None
on_generate_isolation(widget)

Callback for button on Gerber form to create isolation routing geometry.

Parameters:widget – The widget from which this was called.
Returns:None
on_generate_paintarea(widget)

Callback for button on geometry form. Subscribes to the “Click on plot” event and continues after the click. Finds the polygon containing the clicked point and runs clear_poly() on it, resulting in a new FlatCAMGeometry object.

Parameters:widget – The widget from which this was called.
Returns:None
on_gerber_generate_cutout(widget)

Callback for button on Gerber form to create geometry with lines for cutting off the board.

Parameters:widget – The widget from which this was called.
Returns:None
on_gerber_generate_noncopper(widget)

Callback for button on Gerber form to create a geometry object with polygons covering the area without copper or negative of the Gerber.

Parameters:widget – The widget from which this was called.
Returns:None
on_key_over_plot(event)

Callback for the key pressed event when the canvas is focused. Keyboard shortcuts are handled here. So far, these are the shortcuts:

Key Action
‘1’ Zoom-fit. Fits the axes limits to the data.
‘2’ Zoom-out.
‘3’ Zoom-in.
Parameters:event – Ignored.
Returns:None
on_mouse_move_over_plot(event)

Callback for the mouse motion event over the plot. This event is generated by the Matplotlib backend and has been registered in self.__init__(). For details, see: http://matplotlib.org/users/event_handling.html

Parameters:event – Contains information about the event.
Returns:None
on_offset_object(widget)

Offsets the object’s geometry by the vector specified in the form. Re-plots.

Parameters:widget – Ignored
Returns:None
on_options_app2object(param)

Callback for Options->Transfer Options->App=>Object. Copies options from application defaults to the currently selected object.

Parameters:param – Ignored.
Returns:None
on_options_app2project(param)

Callback for Options->Transfer Options->App=>Project. Copies options from application defaults to project defaults.

Parameters:param – Ignored.
Returns:None
on_options_combo_change(widget)

Called when the combo box to choose between application defaults and project option changes value. The corresponding variables are copied to the UI.

Parameters:widget – The widget from which this was called. Ignore.
Returns:None
on_options_object2app(param)

Callback for Options->Transfer Options->Object=>App. Copies options from the currently selected object to application defaults.

Parameters:param – Ignored.
Returns:None
on_options_object2project(param)

Callback for Options->Transfer Options->Object=>Project. Copies options from the currently selected object to project defaults.

Parameters:param – Ignored.
Returns:None
on_options_project2app(param)

Callback for Options->Transfer Options->Project=>App. Copies options from project defaults to application defaults.

Parameters:param – Ignored.
Returns:None
on_options_project2object(param)

Callback for Options->Transfer Options->Project=>Object. Copies options from project defaults to the currently selected object.

Parameters:param – Ignored.
Returns:None
on_options_update(widget)

Called whenever a value in the options/defaults form changes. All values are updated. Can be inhibited by setting self.options_update_ignore = True, which may be necessary when updating the UI from code and not by the user.

Parameters:widget – The widget from which this was called. Ignore.
Returns:None
on_row_activated(widget, path, col)

Callback for selection activation (Enter or double-click) on the Project list. Switches the notebook page to the object properties form. Calls self.notebook.set_current_page(1).

Parameters:
  • widget – Ignored.
  • path – Ignored.
  • col – Ignored.
Returns:

None

on_scale_object(widget)

Callback for request to change an objects geometry scale. The object is re-scaled and replotted.

Parameters:widget – Ignored.
Returns:None
on_toggle_pointbox(widget)

Callback for radio selection change between point and box in the Double-sided PCB tool. Updates the UI accordingly.

Parameters:widget – Ignored.
Returns:None
on_toggle_units(widget)

Callback for the Units radio-button change in the Options tab. Changes the application’s default units or the current project’s units. If changing the project’s units, the change propagates to all of the objects in the project.

Parameters:widget – Ignored.
Returns:None
on_toolbar_replot(widget)

Callback for toolbar button. Re-plots all objects.

Parameters:widget – The widget from which this was called.
Returns:None
on_tools_doublesided(param)

Callback for menu item Tools->Double Sided PCB Tool. Launches the tool placing its UI in the “Tool” tab in the notebook.

Parameters:param – Ignored.
Returns:None
on_tree_selection_changed(selection)

Callback for selection change in the project list. This changes the currently selected FlatCAMObj.

Parameters:selection (Gtk.TreeSelection) – Selection associated to the project tree or list
Returns:None
on_update_plot(widget)

Callback for button on form for all kinds of objects. Re-plots the current object only.

Parameters:widget – The widget from which this was called.
Returns:None
on_zoom_fit(event)

Callback for zoom-out request. This can be either from the corresponding toolbar button or the ‘1’ key when the canvas is focused. Calls self.adjust_axes() with axes limits from the geometry bounds of all objects.

Parameters:event – Ignored.
Returns:None
on_zoom_in(event)

Callback for zoom-in request. This can be either from the corresponding toolbar button or the ‘3’ key when the canvas is focused. Calls self.zoom().

Parameters:event – Ignored.
Returns:None
on_zoom_out(event)

Callback for zoom-out request. This can be either from the corresponding toolbar button or the ‘2’ key when the canvas is focused. Calls self.zoom().

Parameters:event – Ignored.
Returns:None
open_project(filename)

Loads a project from the specified file.

Parameters:filename (str) – Name of the file from which to load.
Returns:None
options2form()

Sets the ‘Project Options’ or ‘Application Defaults’ form with values from self.options or self.defaults.

Returns:None
Return type:None
plot_all()

Re-generates all plots from all objects.

Returns:None
populate_objects_combo(combo)

Populates a Gtk.Comboboxtext with the list of the object in the project.

Parameters:combo (str or Gtk.ComboBoxText) – Name or instance of the comboboxtext.
Returns:None
read_form()

Reads the options form into self.defaults/self.options.

Returns:None
Return type:None
read_form_item(name, dest)

Reads the value of a form item in the defaults/options form and saves it to the corresponding dictionary.

Parameters:
  • name (str) – Name of the form item. A key in self.defaults or self.options.
  • dest (dict) – Dictionary to which to save the value.
Returns:

None

save_project(filename)

Saves the current project to the specified file.

Parameters:filename (str) – Name of the file in which to save.
Returns:None
set_form_item(name, value)

Sets a form item ‘name’ in the GUI with the given ‘value’. The syntax of form names in the GUI is <kind>_app_<name>, where kind is one of: rb (radio button), cb (check button), entry_eval or entry_text (entry), combo (combo box). name is whatever name it’s been given. For self.defaults, name is a key in the dictionary.

Parameters:
  • name (str) – Name of the form field.
  • value (Depends on field kind.) – The value to set the form field to.
Returns:

None

set_list_selection(name)

Marks a given object as selected in the list ob objects in the GUI. This selection will in turn trigger self.on_tree_selection_changed().

Parameters:name (str) – Name of the object.
Returns:None
set_progress_bar(percentage, text='')

Sets the application’s progress bar to a given frac_digits and text.

Parameters:
  • percentage (float) – The frac_digits (0.0-1.0) of the progress.
  • text (str) – Text to display on the progress bar.
Returns:

None

setup_component_editor()

Initial configuration of the component editor. Creates a page titled “Selection” on the notebook on the left side of the main window.

Returns:None
setup_obj_classes()

Sets up application specifics on the FlatCAMObj class.

Returns:None
setup_plot()

Sets up the main plotting area by creating a Matplotlib figure in self.canvas, adding axes and configuring them. These axes should not be ploted on and are just there to display the axes ticks and grid.

Returns:None
Return type:None
setup_project_list()

Sets up list or Tree where whatever has been loaded or created is displayed.

Returns:None
versionCheck()

Checks for the latest version of the program. Alerts the user if theirs is outdated. This method is meant to be run in a saeparate thread.

Returns:None
zoom(factor, center=None)

Zooms the plot by factor around a given center point. Takes care of re-drawing.

Parameters:
  • factor (float) – Number by which to scale the plot.
  • center (list) – Coordinates [x, y] of the point around which to scale the plot.
Returns:

None

class FlatCAM.Geometry
bounds()

Returns coordinates of rectangular bounds of geometry: (xmin, ymin, xmax, ymax).

clear_polygon(polygon, tooldia, overlap=0.15)

Creates geometry inside a polygon for a tool to cover the whole area.

convert_units(units)

Converts the units of the object to units by scaling all the geometry appropriately. This call scale(). Don’t call it again in descendents.

Parameters:units (str) – “IN” or “MM”
Returns:Scaling factor resulting from unit change.
Return type:float
from_dict(d)

Sets object’s attributes from a dictionary. Attributes to include are listed in self.ser_attrs. This method will look only for only and all the attributes in self.ser_attrs. They must all be present. Use only for deserializing saved objects.

Parameters:d (dict) – Dictionary of attributes to set in the object.
Returns:None
get_empty_area(boundary=None)

Returns the complement of self.solid_geometry within the given boundary polygon. If not specified, it defaults to the rectangular bounding box of self.solid_geometry.

isolation_geometry(offset)

Creates contours around geometry at a given offset distance.

Parameters:offset (float) – Offset distance.
Returns:The buffered geometry.
Return type:Shapely.MultiPolygon or Shapely.Polygon
offset(vect)

Offset the geometry by the given vector. Override this method.

Parameters:vect (tuple) – (x, y) vector by which to offset the object.
Returns:None
scale(factor)

Scales all of the object’s geometry by a given factor. Override this method. :param factor: Number by which to scale. :type factor: float :return: None :rtype: None

size()

Returns (width, height) of rectangular bounds of geometry.

to_dict()

Returns a respresentation of the object as a dictionary. Attributes to include are listed in self.ser_attrs.

Returns:A dictionary-encoded copy of the object.
Return type:dict
class FlatCAM.Gerber(Geometry)

ATTRIBUTES

  • apertures (dict): The keys are names/identifiers of each aperture. The values are dictionaries key/value pairs which describe the aperture. The type key is always present and the rest depend on the key:
Key Value
type (str) “C”, “R”, or “O”
others Depend on type
  • paths (list): A path is described by a line an aperture that follows that line. Each paths[i] is a dictionary:
Key Value
linestring (Shapely.LineString) The actual path.
aperture (str) The key for an aperture in apertures.
  • flashes (list): Flashes are single-point strokes of an aperture. Each is a dictionary:
Key Value
loc (list) [x (float), y (float)] coordinates.
aperture (str) The key for an aperture in apertures.
  • regions (list): Are surfaces defined by a polygon (Shapely.Polygon), which have an exterior and zero or more interiors. An aperture is also associated with a region. Each is a dictionary:
Key Value
polygon (Shapely.Polygon) The polygon defining the region.
aperture (str) The key for an aperture in apertures.
  • flash_geometry (list): List of (Shapely) geometric object resulting from flashes. These are generated from flashes in do_flashes().
  • buffered_paths (list): List of (Shapely) polygons resulting from buffering (or thickening) the paths with the aperture. These are generated from paths in buffer_paths().

USAGE:

g = Gerber()
g.parse_file(filename)
g.create_geometry()
do_something(s.solid_geometry)
aperture_parse(gline)

Parse gerber aperture definition into dictionary of apertures. The following kinds and their attributes are supported:

  • Circular (C): size (float)
  • Rectangle (R): width (float), height (float)
  • Obround (O): width (float), height (float).
Parameters:gline (str) – Line of Gerber code known to have an aperture definition.
Returns:Identifier of the aperture.
Return type:str
buffer_paths()

This is part of the parsing process. “Thickens” the paths by their appertures. This will only work for circular appertures. :return: None

create_geometry()

Geometry from a Gerber file is made up entirely of polygons. Every stroke (linear or circular) has an aperture which gives it thickness. Additionally, aperture strokes have non-zero area, and regions naturally do as well.

:rtype : None :return: None

do_flashes()

Creates geometry for Gerber flashes (aperture on a single point).

fix_regions()

Overwrites the region polygons with fixed versions if found to be invalid (according to Shapely).

frac_digits = None

Number of fraction digits in Gerber numbers. Used during parsing.

get_bounding_box(margin=0.0, rounded=False)

Creates and returns a rectangular polygon bounding at a distance of margin from the object’s solid_geometry. If margin > 0, the polygon can optionally have rounded corners of radius equal to margin.

Parameters:
  • margin (float) – Distance to enlarge the rectangular bounding box in both positive and negative, x and y axes.
  • rounded (bool) – Wether or not to have rounded corners.
Returns:

The bounding box.

Return type:

Shapely.Polygon

int_digits = None

Number of integer digits in Gerber numbers. Used during parsing.

offset(vect)

Offsets the objects’ geometry on the XY plane by a given vector. These are:

  • paths
  • regions
  • flashes

Then buffered_paths, flash_geometry and solid_geometry are re-created with self.create_geometry(). :param vect: (x, y) offset vector. :type vect: tuple :return: None

parse_file(filename)

Calls Gerber.parse_lines() with array of lines read from the given file.

parse_lines(glines)

Main Gerber parser. Reads Gerber and populates self.paths, self.apertures, self.flashes, self.regions and self.units.

Parameters:glines (list) – Gerber code as list of strings, each element being one line of the source file.
Returns:None
Return type:None
scale(factor)

Scales the objects’ geometry on the XY plane by a given factor. These are:

  • apertures
  • paths
  • regions
  • flashes

Then buffered_paths, flash_geometry and solid_geometry are re-created with self.create_geometry(). :param factor: Number by which to scale. :type factor: float :rtype : None

class FlatCAM.Excellon

ATTRIBUTES

  • tools (dict): The key is the tool name and the value is the size (diameter).
  • drills (list): Each is a dictionary:
Key Value
point (Shapely.Point) Where to drill
tool (str) A key in tools
offset(vect)

Offsets geometry on the XY plane in the object by a given vector.

Parameters:vect (tuple) – (x, y) offset vector.
Returns:None
parse_file(filename)

Reads the specified file as array of lines as passes it to parse_lines().

Parameters:filename (str) – The file to be read and parsed.
Returns:None
parse_lines(elines)

Main Excellon parser.

Parameters:elines (list) – List of strings, each being a line of Excellon code.
Returns:None
scale(factor)

Scales geometry on the XY plane in the object by a given factor. Tool sizes, feedrates an Z-plane dimensions are untouched.

Parameters:factor (float) – Number by which to scale the object.
Returns:None
Return type:NOne
class FlatCAM.CNCjob(units='in', kind='generic', z_move=0.1, feedrate=3.0, z_cut=-0.002, tooldia=0.0)

Represents work to be done by a CNC machine.

ATTRIBUTES

  • gcode_parsed (list): Each is a dictionary:
Key Value
geom (Shapely.LineString) Tool path (XY plane)
kind (string) “AB”, A is “T” (travel) or “C” (cut). B is “F” (fast) or “S” (slow).
gcode_parse()

G-Code parser (from self.gcode). Generates dictionary with single-segment LineString’s and “kind” indicating cut or travel, fast or feedrate speed.

generate_from_excellon(exobj)

Generates G-code for drilling from Excellon object. self.gcode becomes a list, each element is a different job for each tool in the excellon code.

generate_from_excellon_by_tool(exobj, tools='all')

Creates gcode for this object from an Excellon object for the specified tools.

Parameters:
  • exobj (Excellon) – Excellon object to process
  • tools – Comma separated tool names
Type:

tools: str

Returns:

None

Return type:

None

generate_from_geometry(geometry, append=True, tooldia=None, tolerance=0)

Generates G-Code from a Geometry object. Stores in self.gcode.

Parameters:
  • geometry (Geometry) – Geometry defining the toolpath
  • append (bool) – Wether to append to self.gcode or re-write it.
  • tooldia (bool) – If given, sets the tooldia property but does not affect the process in any other way.
  • tolerance – All points in the simplified object will be within the tolerance distance of the original geometry.
Returns:

None

Return type:

None

linear2gcode(linear, tolerance=0)

Generates G-code to cut along the linear feature.

Parameters:
  • linear – The path to cut along.
  • tolerance (float) – All points in the simplified object will be within the tolerance distance of the original geometry.
Type:

Shapely.LinearRing or Shapely.Linear String

Returns:

G-code to cut alon the linear feature.

Return type:

str

offset(vect)

Offsets all the geometry on the XY plane in the object by the given vector.

Parameters:vect (tuple) – (x, y) offset vector.
Returns:None
plot2(axes, tooldia=None, dpi=75, margin=0.1, color={'C': ['#5E6CFF', '#4650BD'], 'T': ['#F0E24D', '#B5AB3A']}, alpha={'C': 1.0, 'T': 0.3}, tool_tolerance=0.0005)

Plots the G-code job onto the given axes.

Parameters:
  • axes – Matplotlib axes on which to plot.
  • tooldia – Tool diameter.
  • dpi – Not used!
  • margin – Not used!
  • color – Color specification.
  • alpha – Transparency specification.
  • tool_tolerance – Tolerance when drawing the toolshape.
Returns:

None

polygon2gcode(polygon, tolerance=0)

Creates G-Code for the exterior and all interior paths of a polygon.

Parameters:
  • polygon (Shapely.Polygon) – A Shapely.Polygon
  • tolerance (float) – All points in the simplified object will be within the tolerance distance of the original geometry.
Returns:

G-code to cut along polygon.

Return type:

str

pre_parse(gtext)

Separates parts of the G-Code text into a list of dictionaries. Used by self.gcode_parse().

Parameters:gtext – A single string with g-code
scale(factor)

Scales all the geometry on the XY plane in the object by the given factor. Tool sizes, feedrates, or Z-axis dimensions are not altered.

Parameters:factor (float) – Number by which to scale the object.
Returns:None
Return type:None
class FlatCAM.FlatCAMObj(name)

Base type of objects handled in FlatCAM. These become interactive in the GUI, can be plotted, and their options can be modified by the user in their respective forms.

build_ui()

Sets up the UI/form for this object.

Returns:None
Return type:None
deserialize(obj_dict)

Re-builds an object from its serialized version.

Parameters:obj_dict (dict) – Dictionary representing a FlatCAMObj

:return None

plot(figure)

Extend this method! Sets up axes if needed and clears them. Descendants must do the actual plotting.

read_form()

Reads form into self.options.

Returns:None
Return type:None
read_form_item(option)

Reads the specified option from the UI form into self.options.

Parameters:option (str) – Name of the option.
Returns:None
serialize()

Returns a representation of the object as a dictionary so it can be later exported as JSON. Override this method.

Returns:Dictionary representing the object
Return type:dict
set_form_item(option)

Copies the specified option to the UI form.

Parameters:option (str) – Name of the option (Key in self.options).
Returns:None
setup_axes(figure)

1) Creates axes if they don’t exist. 2) Clears axes. 3) Attaches them to figure if not part of the figure. 4) Sets transparent background. 5) Sets 1:1 scale aspect ratio.

Parameters:figure (matplotlib.figure.Figure) – A Matplotlib.Figure on which to add/configure axes.
Returns:None
Return type:None
to_form()

Copies options to the UI form.

Returns:None
class FlatCAM.FlatCAMGerber(name)

Represents Gerber code.

convert_units(units)

Converts the units of the object by scaling dimensions in all geometry and options.

Parameters:units (str) – Units to which to convert the object: “IN” or “MM”.
Returns:None
Return type:None
plot(figure)

Plots the object on to the specified figure.

Parameters:figure – Matplotlib figure on which to plot.
class FlatCAM.FlatCAMExcellon(name)

Represents Excellon/Drill code.

class FlatCAM.FlatCAMCNCjob(name, units='in', kind='generic', z_move=0.1, feedrate=3.0, z_cut=-0.002, tooldia=0.0)

Represents G-Code.

class FlatCAM.FlatCAMGeometry(name)

Geometric object not associated with a specific format.

offset(vect)

Offsets all geometry by a given vector/

Parameters:vect (tuple) – (x, y) vector by which to offset the object’s geometry.
Returns:None
Return type:None
scale(factor)

Scales all geometry by a given factor.

Parameters:factor (float) – Factor by which to scale the object’s geometry/
Returns:None
Return type:None

Indices and tables