Format

Joost Yervante Damad edited this page Aug 19, 2013 · 13 revisions
Clone this wiki locally

for the impatient

All the coffeescript constructs can be found here.

For actual usage I suggest looking at the examples or just try things.

constructors

Constructors are used to make pads, lines, ...

smd and pads

Note that it is perfectly possible to make smds or pads that work fine in madparts but don't work in eagle and/or kicad. Keep the limits of your cad tools in mind :)

example coffeescript constructors

new Smd
new RoundPad r, drill
new SquarePad dia, drill
new LongPad dia, drill
new OctagonPad r, drill
new OffsetPad dia, drill

Smd

attribute default description
x 0 absolute x position of Smd
y 0 absolute y position of Smd
dx 0 width of Smd
dy 0 height of Smd
ro 0 roundness of Smd in %
rot 0 rotation (0,90,180,270 allowed)
name name of Smd

RoundPad

attribute default description
x 0 absolute x position of pad
y 0 absolute y position of pad
r radius of the pad
drill diameter of the drill
drill_dx 0 offset of the drill

RectPad

attribute default description
x 0 absolute x position of pad
y 0 absolute y position of pad
dx 0 width of pad
dy 0 height of pad
drill diameter of the drill
drill_dx 0 offset of the drill
ro 0 roundness of Smd in %
rot 0 rotation (0,90,180,270 allowed)

SquarePad

Equal to RectPad, but dx and dy re equal.

LongPad

A LongPad is just a RectPad with dx = 2*dy and ro = 100.

OctagonPad

attribute default description
x 0 absolute x position of pad
y 0 absolute y position of pad
r radius of the pad
drill diameter of the drill
drill_dx 0 offset of the drill

OffsetPad

An OffsetPad is just a LongPad with a drill_dx of -dy/2.

silk

example coffeescript constructors

new Rect
new Disc r
new Circle w
new Hole drill
new Vertex w
new Line w
new Arc w
new Polygon w
new Name y
new Value y
new Label value

Rect

attribute default description
x 0 absolute x position
y 0 absolute y position
dx 0 width
dy 0 height

Disc

attribute default description
x 0 absolute x position
y 0 absolute y position
r radius

Circle

attribute default description
x 0 absolute x position
y 0 absolute y position
r 0 radius
w width

Hole

attribute default description
x 0 absolute x position
y 0 absolute y position
drill diameter of drill

Vertex

attribute default description
x1 0 absolute x1 position
y1 0 absolute y1 position
x2 0 absolute x2 position
y2 0 absolute y2 position
w width
curve 0 curvage

Line

A Line is just a Vertex with curve=0.

Arc

An Arc is just a vertex with typically curve!=0.

Polygon

attribute default description
w width
v [] list of vertices

Normally you don't manipulate the list of vertices directly, but use the following methods on the Polygon object instead.

method description
start x1,y1 start polygon
add x1,y1(,curve) add a point, with optional curvage
end () end polygon
end curve end polygon with curvage

Note that eagle supports curves in polygons but kicad does not at the moment, meaning the curvage will not be there when exported to kicad.

Label

attribute default description
x 0 absolute x position
y 0 absolute y position
value text to be displayed

Name

A Name is just a Label with the special value "NAME".

attribute default description
x 0 absolute x position
y 0 absolute y position
value "NAME" name of part

Note that madparts assumes the values "NAME" and "VALUE" are special and they map on the special constructs for names and values in both eagle and kicad.

Value

A Value is just a Label with the special value "VALUE".

attribute default description
x 0 absolute x position
y 0 absolute y position
value "VALUE" value of part

Note that madparts assumes the values "NAME" and "VALUE" are special and they map on the special constructs for names and values in both eagle and kicad.

utility functions

  • clone makes a deep copy of an item. You need to take a clone if you want to base another shape on an existing shape.
  • rotate90, rotate180, rotate270 rotate a shape around the origin.
  • rotate90pad, rotate180pad,rotate270pad` are the same, but they only work on pads and smds.
  • mirror_y and mirror_x mirror a shape.
  • adjust_x and adjust_y adjust x or y for a shape.
  • lines creates a sequence of lines with a certain width.
  • silk_square draws a square of silk lines
  • single and single_rot generate a single line of vertical or horizontal pads in a list.
  • dual, alt_dual, rot_dual and alt_rot_dual generate a dual line of vertical or horizontal pads in a list. the alt variants have alternating pad numbers.
  • quad generates a quad layout list of pads.
  • make_rect makes draws a simple rect based on dx, dy, line_width and type.
  • remove allows removing a pad/smd from a list typically generated by one of the single, dual, ... methods above by name

types

Internally madparts classifies layers by types. This table shows how types are mapped onto eagle or kicad layers.

type eagle num eagle name kicad num kicad name
smd 1 Top F.Cu
pad 17 Pads F.Cu
silk 21 tPlace 21 F.SilkS
name 25 tNames F.SilkS
value 27 tValues Dwgs.User
stop 29 tStop 23 F.Mask
glue 35 tGlue 17 F.Adhes
keepout 39 tKeepout
restrict 41 tRestrict
vrestrict 43 vRestrict
docu 51 tDocu 24 Dwgs.User
hole 28 Edge.Cuts