I have several commands I would like to use for different diagrams. For example, I have defined a right 3d angle:
path3 RightAngle(real radius, triple A, triple B, triple C)
{
return B+radius*unit(A-B)--B+radius*(unit(A-B)+unit(C-B))--B+radius*unit(C-B);
}
Now in the same file I can write
draw(RightAngle(0.3,A,H1,C));
This works. Fine. But now I want to draw a right angle in another diagram. Do I have to copy the first code every single time into the new asy-picture or there is the way to put all commands like that into a file MyAsyCommands.asy (or MyAsyCommands.tex, or MyAsyCommands.Idontknowwhat) and then use it like
input MyAsyCommands;
Here they suggest:
You can create your own package by simply creating a new .asy file (say MyMacros.asy) with your own definitions in it, and saving it in the directory in which Asymptote is installed (C:\Program Files\Asymptote by default). Then import MyMacros; in your document, and you'll be set!
I am using ubuntu and have no idea where asymptote is. Yes, I know, shame on me, but shouldn't it be easier than that? I tried to put the file MyAsyCommands.asy into the folder where my file with asy-picture is. (test.tex with \begin{asy}\end{asy}). It didn't work. Namely, this works:
\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
settings.outformat = "pdf";
settings.render = 0;
import three;
//import MyAsyCommands;
size(7cm, 0);
currentprojection=orthographic((5,2,3));
triple A=(0,0,1);
triple B=(0,1,0);
triple C=(1,0,0);
draw (A--B--C);
dot(Label("$A$",align=N),A);
dot(Label("$B$",align=E),B);
dot(Label("$C$",align=W),C);
//draw(RightAngle(0.3,A,B,C));
\end{asy}
\end{document}
But when I take comments out, inputing the file MyAsyCommands.asy:
path3 RightAngle(real radius, triple A, triple B, triple C)
{
return B+radius*unit(A-B)--B+radius*(unit(A-B)+unit(C-B))--B+radius*unit(C-B);
}
it doesn't. Probably MyAsyCommands.asy should be somehow specially desined (you know when we do the same in LaTeX we use \RequirePackage instead of \usepackage) or something like that.
What do I do wrong?
import
line?import MyAsyCommands;
ought to work fine as is. So I'm trying to figure out why it doesn't; if it's a bug in Asymptote, we should probably report it.