Cloning
How-to


Related Pages

Clone Element, Clone Page, Deep Cloning, Clone Group, Groups, Edit the net, Add/edit inscriptions

Cloning

Cloning allows parts of the structure of a net to be reused, either elsewhere in the net or in other nets.

Cloning individual elements

Cloning an element of a CP-net, e.g. a place, is designed to be similar in use to the Create tools. Once the element has been cloned the tool in hand is similar to a create tool, except that the attributes of the created element are the same as those of the one being cloned. In the case of arcs the shape of the arc is determined when the clone is placed on the page, in the same way as with the Create Arc tool.

Inscriptions can also be cloned. Doing so will result in a cursor with the inscription attached that may be applied to a suitable element. This can be used to easily copy complicated inscriptions, e.g. arc inscriptions or code segments, that are needed in several places.

Cloning groups of elements

Cloning of groups of elements is an extension of the basic cloning, where more than one element is cloned at the same time.

Cloning a group

If a group is selected, and the target of the clone tool is a member of the selected group, then the elements in the group will be cloned. As with cloning of individual elements, the result is a cursor with the cloned elements attached that may be used to insert them one or more times.

Note that there are some restrictions on what can be cloned in this way. The cloned group of elements must not have any dangling arcs (arcs with one or two endpoints not in the group), attempting to clone a group with dangling arcs result in an error message similar to the one below. Similarly inscriptions cannot be cloned as part of a group unless the element they are attached to is also in the group.

Cloning a group with dangling arcs

If a group of elements contains substitution transitions, then new instances of the subpages will be created when the group of elements is cloned, i.e. the subpages are not cloned. Cloning subpages is described on the help page for deep cloning.

Clone Between Nets

Every cloned element can be placed in a arbitrary open net. In this way cloned elements can be transported across net. The same goes for groups of elements, meaning you can clone entire groups of elements to other nets.

Cloning subpages between nets

Cloning subpages between nets is somewhat complicated. The hierarchical relationships that are created in the new net depend on the way in which new objects are created, as described below.

Assume that a group of elements containing a substitution transition has been cloned in one net by applying the Clone element tool to an element in a group. The tool-in-hand is now a clone of a group of elements.

Cloned group with substitution transition

When this tool is applied several times in another net before applying the Drop Tool tool, then several instances of the subpages will be created. For example, applying the tool, shown above, two times in a net (different from the net from which the clone was made) will result in two instances of the page named Subpage (clone). These instances are shown below as Subpage (clone) (1) and Subpage (clone) (2).

Subpage instances in new net from clone

Another way to clone subpages between nets is to:

  1. Clone a group of elements including a substitution transition in one net.
  2. Apply the tool-in-hand, i.e. create copies of the original elements, to a page in another net.
  3. Reset the Clone Element tool, e.g. by applying the Drop Tool tool or by quitting CPN Tools.
  4. Repeat steps 1. and 2. using the same nets.

In this case, independent copies of the subpages will be created, i.e. new instances of the same subpage will not be created. These independent copies of the subpage will have the same name, e.g. Subpage (clone), but they will otherwise be unrelated to each other. In the example below, the two pages named Subpage (clone) are completely independent from each other.

Independent copies of subpages in new net from clone

Clone Page

Cloning a page

The clone instrument also allows cloning of a page, or a hierarchy of pages. In this case a new page is created for each page in the cloned hierachy (the page being cloned and all of its subpages), each with the text "(clone)" appended to its name.

The top page will be cloned, and it will be independent of the original page, but for all subpages, there will be created new instances of the original subpages. Once pages have been cloned, it is possible to rearrange them in the hierachy (as described in Working with hierarchical nets) if need be.

Guidelines, groups and fusion sets are also cloned to the new page containing the cloned elements of the original page.

Currently it is not possible to clone a page between nets. A workaround to this problem is to create a new page in the other net. Then clone the elements of the page you wish to clone and place them on the new page in the other net. Since guidelines can not be part of a group and groups can not be part of another group, so guidelines and group have to be made by hand also. Notice any guideline or group on subpages of the elements cloned to the new page will have their guidelines and groups to the new net.

Clone Group

Cloning a group is not the same as cloning the elements of a group. When a group is cloned, a new group is created with (initially) the same members as the original group. Members may then be added to or removed from the new group using the Toggle group tool, as if the group had been created with New Group.

Clone Fusion Set

Cloning a fusion set (see Fusion places) will simply add a place to the fusion set if it is cloned within the new of the cloned fusion set. If it is cloned to another net a fusion set is made and the following places the cloned fusion set is applied to will be add to the cloned fusion set.