## draw_pnp plugin

The optional draw_pnp plugin can auto-generate a pair of helper doc layers for pick-and-place. The layers contain autogenerated graphics for:

- an optional frame around each subcircuit (to indicate position)
- an optional filled circle mark in the center of terminal 1 (to indicate orientation)
- the refdes text printed approximately at the subcircuit's origin (not in the p&p origin)

The two layers are for top and bottom; autogenerated graphics for the subcircuits placed on the top side of the board go on the top layer while bottom side subcircuits go on the bottom layer. Both layers are optional, it is possible to have zero, only one of them or both of them.

The easiest way to create the layers is executing the DrawPnpLayers(create) action or invoke the action from the menu system: right click over a layer group name (vertically printed text in the layer selector's left side), "Create new group" menu in the context popup, "Create pnp helper..." menu. The action creates both top and bottom layer group and layer. If only one of them is needed, the other group should be removed by invoking the same context menu over the name of the layer group (not the layer), selecting the "Remove group" submenu.

The default config for the cam plugin contains rules for exporting pnp helper documentation. These rules are called doc_pnp_*. This feature is accessible using the File menu, "Export with CAM..." submenu.

### Tips & tricks, extras

The pnp doc layers are also editable and can host user drawn objects. It's recommended to draw pick-and-place related instructions onto these layers.

Layer compositing works normally: the layer can be turned into a 'sub' layer making it inverted. It's possible to create multiple layers within the layer group, both positive and negative layers; adding a negative layer at the end of the group allows the user to erase some of the autogenerated documentation.

Rendering details such as text scale, text/line/dot thickness can be fine tuned in the config tree (see: preferences dialog, rightmost tab). The subtree of interest is plugins/draw_pnp.

### Technical details on layer groups and layers

The layer group needs to be created so that:

- its type is doc
- its location is either top or bottom
- its purpose is: pnp
- usually the group has the attribute init-inivis=1 so that it's made invisible after loading the board

The layer (within this group) where automatically generated graphics should go must have the attribute pcb-rnd::plugin_draw=draw_pnp

There can be multiple layers having the pcb-rnd::plugin_draw=draw_pnp attribute and all of them will run the renderer. The layer does not have to be in a doc layer group - it can be on silk or even copper, but beware: the plugin is a rendering trick; even when it renders onto a copper layer, it will not actually create objects so the auto-generated graphics will be invisible to connectivity checks and poly clipping. It's strongly recommended to have these layers only in doc layer groups.

The default cam export job will look for top or bottom doc layer groups with the purpose set to pnp. Any deviation from that will not export with the stock cam config (but it's easy to write custom cam jobs that pick up the layer group differently.)

### Technical details on rendering and compatibility

The plugin uses the so called plugin_draw mechanism where the core layer renderer calls a plugin provided function instead of doing the normal rendering. The plugin hooks the plugin_draw function on layers that have the pcb-rnd::plugin_draw=draw_pnp, regardless of layer group properties.

Since this mechanism depends only on a layer attribute, a file created with a pcb-rnd having the draw_pnp plugin will still be loadable using a pcb-rnd not having the plugin. Custom user drawn objects will appear properly, but the pcb-rnd that lacks draw_pnp obviously won't render the auto-generated graphics. However, using this feature it is not possible to break backward or forward compatibility of board files to a level that the board gets unloadable.