FullControl API Reference

Practical summary of the classes and functions you call from the py2g editor. Everything you run executes inside Pyodide (CPython), so you never install anything locally.

Runtime Scaffold

Every sketch loads a scaffold before your code runs. It injects steps, printer defaults, and the FullControl module so you can focus purely on geometry and controls.

Runtime ScaffoldPython
import fullcontrol as fc
steps = []
printer_name = 'generic'
steps.append(fc.Extruder(on=True))
steps.extend(fc.rectangleXY(
start_point=fc.Point(x=0, y=0, z=0.2),
x_size=20,
y_size=20
))

💡 Variant Note

py2g ships with the official FullControl PyPI package inside Pyodide. js2g bundles the npm build inside a sandboxed worker. API names stay the same, so switching between variants is trivial.

Core Building Blocks

Objects you will instantiate in almost every sketch.

fc.Point

Single XYZ position with optional metadata like extrusion state, per-move speed, and viewer color overrides.

  • x (optional, default: 0) – X coordinate in millimeters relative to the printer origin.
  • y (optional, default: 0) – Y coordinate in millimeters.
  • z (optional, default: 0) – Z height in millimeters (layer height or custom toolpath elevation).
  • extrude (optional, default: false) – Set true to treat this move as an extrusion segment.
  • speed (optional, default: inherits active speed) – Optional override in mm/s for this move (otherwise inherits the active print/travel speed).
  • color (optional, default: auto) – Optional [r, g, b] tuple rendered when PlotControls.color_type is set to manual.

Returns: Point instance ready to append to steps or feed into geometry helpers.

fc.Vector

Direction + magnitude helper used by move(), ramp helpers, and polar utilities.

  • x (optional, default: 0) – X component of the vector.
  • y (optional, default: 0) – Y component of the vector.
  • z (optional, default: 0) – Z component of the vector.

Returns: Vector that can be added to Points or reused across multiple transforms.

fc.ExtrusionGeometry

Defines the bead cross-section so downstream transforms can compute flow and visualization.

  • area_model (optional, default: rectangle) – One of 'rectangle', 'stadium', 'circle', or 'manual'. Determines which other fields are read.
  • width (optional, default: printer default) – Line width in millimeters (rectangle + stadium).
  • height (optional, default: printer default) – Layer height in millimeters (rectangle + stadium).
  • diameter (optional, default: line width) – Cross-section diameter in millimeters (circle model).
  • area (optional, default: calculated automatically) – Manual area override in mm² when area_model = manual.

Returns: ExtrusionGeometry object referenced by fc.transform and viewer pipelines.

Geometry & Movement

Mix these helpers to build precise toolpaths without manual coordinate crunching.

Shapes & Paths

High-level constructors that emit complete loops or paths on a constant Z plane.

fc.rectangleXY

Generate a 2D XY rectangle starting and ending at a given Point (5 points returned), with specified size.

  • start_point – The starting point of the rectangle.
  • x_size – The size of the rectangle in the X-axis.
  • y_size – The size of the rectangle in the Y-axis.
  • cw (optional, default: False) – Specifies the direction of the rectangle. If True, the rectangle is generated in a clockwise direction. If False (default), the rectangle is generated in a counter-clockwise direction.

Returns: list: A list of five Points representing the rectangle. The list begins and ends with the same Point.

fc.circleXY

Generate a 2D-XY circle with the specified number of segments (defaulting to 100), centred about a Point,

  • centre
  • radius
  • start_angle
  • segments (optional, default: 100)
  • cw (optional, default: False)

Returns: list: A list of Points representing the circle.

fc.ellipseXY

Generate a 2D-XY ellipse with the specified number of segments (defaulting to 100), centred about a Point,

  • centre
  • a
  • b
  • start_angle
  • segments (optional, default: 100)
  • cw (optional, default: False)

fc.polygonXY

Generate a 2D-XY polygon with the specified number of sides, centered about a Point, sized based on the enclosing radius,

  • centre
  • enclosing_radius
  • start_angle
  • sides
  • cw (optional, default: False)

Returns: - list: A list of Point objects representing the vertices of the polygon. The list will have one more Point than the number of sides, since it begins and ends with the same Point.

fc.spiralXY

Generate a 2D-XY spiral with the specified number of segments and turns (partial turns permitted), centred about a Point, defaulting to anti-clockwise.

  • centre
  • start_radius
  • end_radius
  • start_angle
  • n_turns
  • segments
  • cw (optional, default: False)

fc.helixZ

Generate a helix in the Z direction with the specified number of segments and turns (partial turns permitted), centred about the Point centre, sized based on the start and end radius,

  • centre
  • start_radius
  • end_radius
  • start_angle
  • n_turns
  • pitch_z
  • segments
  • cw (optional, default: False)

Arcs & Segments

Precise arc helpers plus segmentation utilities for custom resolution.

fc.arcXY

Generate a 2D-XY arc with angles defined in radians and z-position the same as that of the centre point.

  • centre – The center point of the arc.
  • radius – The radius of the arc.
  • start_angle – The starting angle (radians) of the arc.
  • arc_angle – The angle (radians) of the arc.
  • segments (optional, default: 100) – The number of segments to divide the arc into. Defaults to 100.

Returns: list: A list of Points representing the arc.

fc.arcXY_3pt

Generate a 2D-XY arc passing through three specified points.

  • pt1 – The starting point of the arc.
  • pt2 – An intermediate point that the arc passes through.
  • pt3 – The ending point of the arc.
  • segments (optional, default: 100) – The number of segments to divide the arc into. Defaults to 100.

Returns: list: A list of Points representing the arc from pt1 through pt2 to pt3.

fc.variable_arcXY

Generate a arc with optionally varying radius and z-position. angles are defined in radians. z-position starts the same as that of the centre point and increased by z_change.

  • centre
  • start_radius
  • start_angle
  • arc_angle
  • segments (optional, default: 100)
  • radius_change (optional, default: 0)
  • z_change (optional, default: 0)

fc.segmented_line

Return a list of Points linearly spaced between the start Point and end Point.

  • point1
  • point2
  • segments

Returns: list: A list of Points linearly spaced between the start and end Points.

fc.segmented_path

Calculate a segmented path (equidistant points) based on a list of points and the desired number of segments.

  • points – A list of equidistant points along the path.
  • segments – The desired number of segments.

Returns: list: A list of points representing the segmented path.

Movement Helpers

Travel and positioning tools used to stitch geometry together.

fc.travel_to

Returns a list of objects to turn extrusion off, travel to a point, then turn extrusion on.

  • geometry – The destination point to travel to or the list of points to which the first point in the list will be travelled to.

Returns: list: A list of objects representing the steps to perform the travel.

fc.move

Move 'geometry' (a Point or list of steps including Points) by 'vector'.

  • geometry
  • vector
  • copy (optional, default: False)
  • copy_quantity (optional, default: 2)

Returns: Union[Point, list]: The new geometry after being moved. If 'geometry' is a Point, a new Point is returned. If 'geometry' is a list, a new list with the modified Points is returned.

fc.move_polar

Move 'geometry' (a Point or list of steps including Points) about a

  • geometry
  • centre
  • radius
  • angle
  • copy (optional, default: False)
  • copy_quantity (optional, default: 2)

Returns: Union[Point, list]: The new geometry as a list (original geometry is not edited).

fc.relative_move

Convenience helper that offsets a point or last point in a list by a vector.

  • point_or_steps – Single point or array whose last point will be used.
  • vector – Vector describing the delta to apply.

Returns: New point after the relative move.

fc.polar_to_point

Convert polar coordinates to Cartesian coordinates.

  • centre – The center point.
  • radius – The radius.
  • angle – The angle (radians).

Returns: Point: A new Point object with x, y, and z coordinates calculated based on the given polar coordinates.

fc.point_to_polar

Convert a Cartesian point to polar coordinates.

  • target_point – The target point in Cartesian coordinates.
  • origin_point – The origin point in Cartesian coordinates.

Returns: PolarPoint: The polar coordinates of the target point relative to the origin point, accessed with .radius and .angle

Waves & Patterns

Programmatic infill utilities and coordinate ramps.

fc.squarewaveXY

Generate a square wave with the set number of periods, starting at the start_point, with

  • start_point
  • direction_vector
  • amplitude
  • line_spacing
  • periods
  • extra_half_period (optional, default: False)
  • extra_end_line (optional, default: False)

fc.trianglewaveXY

Documentation not yet available for this API.

fc.sinewaveXY

Documentation not yet available for this API.

fc.ramp_xyz

Linearly increase x/y/z values of a list of Points by x_change/y_change/z_change.

  • steplist – List of Points to be modified.
  • x_change (optional, default: 0) – Amount to increase x value of each Point. Default is 0.
  • y_change (optional, default: 0) – Amount to increase y value of each Point. Default is 0.
  • z_change (optional, default: 0) – Amount to increase z value of each Point. Default is 0.

Returns: list: List of Points with modified x/y/z values.

fc.ramp_polar

Linearly changes the angle (radians) and radius of a list of Points about a given centre point.

  • steplist – A list of Points to be modified.
  • centre – The centre point about which the Points are modified.
  • radius_change (optional, default: 0) – The amount by which to change the radius of each Point. Defaults to 0.
  • angle_change (optional, default: 0) – The amount by which to change the angle (radians) of each Point. Defaults to 0.

Returns: list: A list of modified Points.

Printer Controls & States

Insert these steps anywhere to change printer behavior mid-design.

Flow & Extrusion

Stateful objects inserted into the steps list to change how upcoming moves behave.

fc.Extruder

Turns extrusion on/off and configures filament properties.

  • on (optional, default: true) – True enables extrusion, false triggers a travel move.
  • units (optional, default: mm) – 'mm' for filament length or 'mm3' for volume-based flow.
  • dia_feed (optional, default: 1.75) – Filament diameter used for volume conversion.
  • relative_gcode (optional, default: false) – Emit relative extrusion commands when true.
  • retraction_length (optional, default: profile default) – Default retraction length in mm.
  • retraction_speed (optional, default: profile default) – Default retraction speed in mm/s.

Returns: Extruder state change appended to steps.

fc.Retraction

Overrides the next retraction event with custom values.

  • length (optional, default: extruder default) – Retraction distance in mm (falls back to Extruder defaults).
  • speed (optional, default: extruder default) – Retraction speed mm/s.

Returns: Command that retracts filament at the specified settings.

fc.Unretraction

Explicit unretraction helper mirroring Retraction parameters.

  • length (optional, default: extruder default) – Unretraction distance in mm.
  • speed (optional, default: extruder default) – Unretraction speed mm/s.

Returns: Command that restores filament flow after a retract.

fc.ExtrusionRate

Scales the requested flow rate without editing geometry.

  • rate (optional, default: 1.0) – Multiplier applied to the nominal flow.

Returns: Extrusion rate change affecting subsequent moves.

fc.StationaryExtrusion

Deposits material without moving (ooze shields, blobs, primers).

  • volume – Volume or filament length to extrude.
  • speed (optional, default: 5) – Extrusion speed mm/s.

Returns: Extrusion command at the current position.

Speeds & Environment

Adjust velocities, temperature, and cooling mid-print.

fc.PrintSpeed

Sets the speed for extrusion moves.

  • speed – Print speed in mm/s.

Returns: Print speed override until changed again.

fc.TravelSpeed

Sets the speed for travel (non-extruding) moves.

  • speed – Travel speed in mm/s.

Returns: Travel speed override for future moves.

fc.Hotend

Controls nozzle temperature and optional wait behavior.

  • temp – Target temperature in deg C.
  • wait (optional, default: true) – When true, waits until the target temp is reached before continuing.
  • tool (optional, default: 0) – Tool index for multi-extruder printers.

Returns: Temperature command inserted into the G-code stream.

fc.Buildplate

Sets bed temperature.

  • temp – Target temperature in deg C.
  • wait (optional, default: true) – Wait for the bed before continuing.

Returns: Bed temperature command.

fc.Fan

Controls part cooling fan speed.

  • speed_percent (optional, default: 100) – Fan speed from 0-100%.

Returns: Fan speed command.

Runtime Metadata

Metadata that shapes visualization, exported G-code, and printer profiles.

fc.GcodeControls

Sets printer name, header info, and export behavior.

  • printer_name (optional, default: generic) – Device profile name (matches fullcontrol profiles).
  • initialization_data (optional, default: {}) – Object of values injected into the printer profile (temps, primer selection, etc.).
  • save_as (optional, default: sketch.gcode) – Filename used when downloading G-code.
  • include_date (optional, default: true) – Adds a timestamp comment to the file header.
  • show_banner (optional, default: true) – Add the FullControl banner to the output.
  • show_tips (optional, default: true) – Include printing tips in comments.
  • silent (optional, default: false) – Suppress console warnings during transforms.

Returns: Controls object passed to fc.gcode or fc.transform.

fc.PlotControls

Tweaks how the Plotly viewer displays geometry.

  • color_type (optional, default: z_gradient) – 'z_gradient', 'print_sequence', 'print_sequence_fluctuating', 'random_blue', or 'manual'.
  • style (optional, default: tube) – 'tube' for shaded extrusions or 'line' for polylines.
  • hide_travel (optional, default: false) – Hide gray travel moves.
  • hide_axes (optional, default: false) – Hide XYZ axes.

Returns: Viewer config object consumed by the editor visualizer.

fc.PlotAnnotation

Adds labels to specific coordinates in the viewer.

  • point – Point to annotate.
  • label – Text shown in the viewer.

Returns: Annotation entry layered on top of the viewer.

fc.PrinterCommand

Injects a device-specific command from the printer profile.

  • id – Key referencing the command (e.g., home, purge).

Returns: Command resolved to G-code during export.

fc.ManualGcode

Allows raw G-code snippets inside your design.

  • text – Exact G-code lines to insert.

Returns: G-code lines inserted verbatim.

fc.GcodeComment

Adds a human-readable comment to the export.

  • text – Comment body.

Returns: Comment line prefixed with ; in the G-code output.

Utility Helpers

Speed up analysis, math, and import/export flows.

Analysis & Cleanup

Helpers that validate and normalize your steps array.

fc.check

Check a list of steps and report what type of classes are included and whether the list is 2D.

  • steps

fc.fix

Documentation not yet available for this API.

fc.flatten

Takes a list in which some elements are lists in the second dimension.

  • steps

Returns: list: A flattened 1D list.

fc.points_only

Converts steps of Points and control to only Points and returns a new list.

  • steps – A list of steps containing Points and control data.
  • track_xyz (optional, default: True) – Specifies whether to track the xyz values of the Points. If True, the returned list will contain a tracked list of points with all xyz values defined. If False, the Points are returned as they are defined, including attributes with value=None.

Returns: list: A new list containing only Points.

Math Helpers

Quick geometry calculations you can reuse across sketches.

fc.distance

Calculate the Euclidean distance between two points in 3D space.

  • point1
  • point2

Returns: float: The distance between the two points.

fc.angleXY_between_3_points

Returns the angle from start_point to end_point, about mid_point.

  • start_point
  • mid_point
  • end_point

fc.path_length

Calculates the total length of a path defined by a list of points.

  • points – A list of points defining the path.

Returns: float: The total length of the path.

fc.linspace

Generate evenly spaced floats from start to end.

  • start – The starting value of the range.
  • end – The ending value of the range.
  • number_of_points – The number of points to generate.

Returns: list: A list of number_of_points floats, including the start and end values.

fc.midpoint

Return the mid-point between two points.

  • point1 – The first point.
  • point2 – The second point.

Returns: Point: The mid-point between the two points.

fc.centreXY_3pt

Calculate the centre point of a circle passing through three points.

  • pt1 – First point on the circle.
  • pt2 – Second point on the circle.
  • pt3 – Third point on the circle.

Returns: Point: centre point.

State & I/O

Share data across steps or persist designs to disk.

fc.relative_point

Returns an fc.Point object with x, y, z positions relative to a reference point.

  • reference – The reference point or a list of points. If a list is supplied, the last point in the list is used as the reference point.
  • x_offset – The offset in the x-axis.
  • y_offset – The offset in the y-axis.
  • z_offset – The offset in the z-axis.

Returns: fc.Point: A new fc.Point object with the updated x, y, z positions.

fc.first_point

Return the first Point in the list.

  • steps
  • fully_defined (optional, default: True)

Returns: - Point: The first Point in the list.

fc.last_point

Return the last Point in the list.

  • steps
  • fully_defined (optional, default: True)

Returns: - Point: The last Point in the list.

fc.export_design

Export design (list of steps) to a JSON file.

  • steps
  • filename

Returns: None

fc.import_design

Import a previously exported design (list of steps).

  • fc_module_handle – The fc module that was imported to create the design originally (typically fc in documentation).
  • filename – The name of the file to import the design from (without the .json extension).

Returns: A list of steps representing the imported design.

fc.build_default_registry

Documentation not yet available for this API.

fc.import_printer

Documentation not yet available for this API.

Pipeline Outputs

These helpers convert your steps list into something tangible.

fc.gcode

Generate a gcode string from a list of steps.

  • steps – A list of step objects.
  • gcode_controls – An instance of GcodeControls class. Defaults to GcodeControls().
  • show_tips

Returns: str: The generated gcode string.

fc.visualize

Visualize the list of steps.

  • steps
  • plot_controls
  • show_tips

fc.transform

Transform a fullcontrol design (a list of class instances) into the specified result_type.

  • steps
  • result_type
  • controls (optional, default: None)
  • show_tips (optional, default: True)

Returns: - The transformed result based on the specified result_type.

Further Reading

Dive into the upstream docs for exhaustive API details.