Getting Started
CnD is integrated into the Forge pedagogic model finder, which is heavily inspired by the Alloy tool and language. This guide assumes you have a basic understanding of Forge or Alloy. If you need an introduction to Forge, check out the Forge documentation.
Installing CnD
You can install CnD in one of the following ways:
- A stable, but less often updated version of CnD is packaged with the Forge VS Code Extension. This automatically launches CnD at
localhost:3000
. - NPM: CnD is available as an NPM package. You can install and launch CnD as follows:
1 2 |
|
- From a specific GitHub release : Download
CnD
from GitHub releases and runnode index.js
Running CnD with Forge
These instructions assume that you have an actively running CnD
server on port 3000. If you are using the Forge VS Code Extension, you will not have to manually launch CnD.
- Run a Forge specification that includes a
run
statement (an example is available here). - This will open up Sterling, the default Forge visualizer, in a browser window.
Run your command, and then, once Sterling displays a graph, click the
Layout
drawer. SelectLoad Layout
to load the graph in Cope and Drag. If you already have a Cope and Drag specification, you can paste it in here before clicking load layout.

- CnD will now open in a different tab. You can now start adding constraints that define spatial relationships between elements and directives that control visual styling and representation.
These can be expressed both via YAML and a structured, no-code interface.
If you are just starting with
CnD
, we recommend beginning with the No Code interface.


- Once you have clicked 'Apply Layout',
CnD
will apply your specification to generate a new diagram.
Running CnD with Alloy
For the moment, the best way to use CnD with Alloy is by pasting the instance XML that Alloy produces into CnD directly. To do this:
- From within Alloy's instance visualizer, select the
File -> Export To -> XML
menu option.

-
Open the XML file in a text editor and copy its entire contents to clipboard.
-
Click the
Edit Datum
button in theCnD
Layout pane, then paste the XML into the edit box. -
Click
Apply Layout
. The instance will be displayed andCnD
constraints and directives will be available for visualization. This includes selectors that use the (substantial) set of operators shared by both Forge and Alloy: join, set comprehension, cardinality, and so on.
Next Steps
- Read about Constraints
- Learn about Directives