OmniGraffle template and script to generate cards from data.
Features:
- merge data property values with graphic's text
- style graphics based on a data property from visual style prototype
- export individual cards as individual files
Requires OmniGraffle version ≥ 7.18.
To install the script in OmniGraflle do the following steps:
- open OmniGraffle
- Select menu Automation → Configure…
- Select Add Linked Folder
- Select the CardMaker folder in this repository containing the scripting files.
- Open the CardMaker.graffle document
- Select menu Automation → Create Cards
- Cards are generated in the sheet named
sheet
You can export cards as PDFs or any other format individually:
- Select the canvas named
sheet
- Menu File → Export… or
Cmd+Opt+E
- Chose your format: PNG, PDF, ...
- Check ✅ Export from artboards only
This will generate one file per card with filename being the card's name.
The template document has a specific content.
- Document MUST contain sheet named
template
- Sheet named
template
MUST contain an object with namecard
and it MUST be a group - Document MUST contain sheet named
card
. Content will be replaced - Document MUST contain sheet named
sheet
. Content will be replaced.- Sheet named
sheet
must contain a layer layer namedsheet
- Sheet named
sheet
must contain an artboard layer namedartboard
- Sheet named
Cards data are read from a JSON file. The JSON file is a dictionary.
Keys:
cards
: array of cards represented as dictionaries
Card structure is left to the author of the template and the cards. The following properties are expected by the provided template:
name
– card name/labeltype
– card typetext
– card body text
Card template is stored in a sheet named template
. It is a group of graphics that has name card
.
Card template graphic objects name denotes which field will be used as the graphic's text. For example, if the template has a text object with name label
it will be replaced by value of card's property label
.
Graphic's user data:
styleProperty
– name of card’s property that contains name of the style to be applied to the object (see more about styles below)
Objects can be styled based on value of card's property. Style is specified by creating another object with that style. This approach makes it visually explicit how the styles look like instead of hiding it in an obscure textual representation.
The objects representing styles are objects in the canvas template
. They are identified by having a user property type
set to style
. Their name denotes the style name.
Cards have a property type
that can be either action
or resource
. We want to have action cards to have a red border and resource cards to have a green border. We create two border-like templates: one red and one green. Canvas will have the following style objects:
- red rectangle with name
action
andtype
set tostyle
- green rectangle with name
resource
andtype
set tostyle
The card template would have a rectangle object with styleProperty
set to type
. It can be styled in some default style that will be used when the cards type
contains unknown type or a type that is not to be styled differently.
- Stefan Urbanek [email protected]
- Template: Attribution-ShareAlike 4.0
- Code: MIT