# how do I create a named subdiagram?

I'm just learning how to use Asymptote. I've rendered a somewhat complex diagram including several paths and circles, simply using commands like `draw((1,2)..(3,4))`, but now I'd like to repeat that diagram several times at different centerpoints. So either I need to assign the list of commands to a subroutine, or somehow assign them to a variable which I can call the `draw` method on. The documentation is inexplicably mute on this question.

-
This is one of the problems of using a pacakge that generates the `tikz` macro calls. Packages like this are only useful for one-of diagrams (and only if they are really complicated). You would need to go thru the output, and change the coordinates such that they are relative to an origin. Then you could easily repeat the figure, and customize it on a per use. Unless your diagram is extremely complicated you are better off doing it in `tikz` directly. I would need to have an idea of what the diagram looks like to offer more specific advice. – Peter Grill Oct 17 '12 at 0:29
I'm really not sure what is wanted here as an answer, so I've closed. Please edit and request reopening. – Joseph Wright Jul 7 '13 at 7:58
Reopened on request from answerer – Martin Scharrer May 20 '15 at 21:24

In `asymptote` you may accomplish this by drawing on a `picture` other than `currentpicture`. Here I create and draw on `picture` `p`. `picture` `p` is then drawn on `currentpicture` using the `add` command, with transformations applied. The `asymptote` manual has a section on the use of pictures.

``````unitsize(1cm);
picture p;
draw(p, scale(1,2)*unitsquare);
label(p, "\$A\$", (1,0), NW);
fill(p, scale(0.3,0.3)*unitcircle, red);