Asymptote

Exporting meshes to Asymptote code

Introduction
Asymptote is a programming language with which you can create figures and graphs in two and three dimensions. An Asymptote program can be stored in a file and compiled individually. In this way, it is possible to generate eps or pdf files, among other formats. But you can also choose to include the Asymptote code in a LaTeX document. In this case, you can include the Asymptote code in the same file where you have the LaTeX document or, if you prefer, you can store the Asymptote program in another file and then include it in the file where you have the LaTeX code. The pdf-2D files generated from Asymptote codes can be viewed in any available pdf reader. For the 3D figures obtained from Asymptote programs, you can choose between creating a still image of the 3D figure from a chosen point of view or you can generate an interactive pdf-3D file. As in the first case, files containing static images can be read with any pdf file reader. Until now, in order to interact with the pdf-3D files that are created using Asymptote, the Acrobat Reader program in version 9 or higher must be used.

Generating Asymptote code from FreeCAD.
Thanks to the developer wmayer, to date FreeCAD from version 0.19 -rev22411, can generate Asymptote codes from meshes created with the Mesh Design Workbench. The process is the following:
 * 1) In a FreeCAD document, create a 3d object, using for example the [[Image:Workbench_Part.svg|24px]] Part Workbench or [[Image:Workbench_PartDesign.svg|24px]] PartDesign Workbench.
 * 2) You can assign colors to the faces of your choice, as you would normally do:
 * 3) In the document tree diagram, right-click the object you want to modify the colors.
 * 4) In the dialog that appears, select: "Adjust colors".
 * 5) Next, in the 3D view, one face at a time, click on the desired face and then, in the tasks tab, click on the button that is just below Faces [] then you can select the color you decide.
 * 6) Press
 * 7) Change to the [[Image:Workbench_Mesh.svg|24px]] Mesh Design Workbench.
 * 8) Create a mesh of the desired object.
 * 9) With one click, select the object to export.
 * 10) From the menu, select . Or equivalently, on the toolbar, click on [[Image:Mesh_FromPartShape.svg|32px]] Create mesh from shape... icon.
 * 11) In Tasks, select the desired options (such as colors, etc.) and then click the.
 * 12) Export the meshing to Asymptote code:
 * 13) Select the created mesh.
 * 14) On the toolbar press [[Image:Mesh_Export.svg|32px]] Export mesh... icon or follow the menu sequence:.
 * 15) In the lower part of the window that will appear, select the appropriate file type: Asymptote format (*.asy).
 * 16) Choose between leaving its default name or change it if you like, for example to AsymptoteFileName.asy.
 * 17) Ready, you have the Asymptote code with which you can generate, for example, a pdf file with the figure you selected in FreeCAD.
 * 18) Generating a pdf file from the Asymptote code.
 * 19) The Asymptote compiler is called asy.
 * 20) You can compile the generated file directly using the command line: asy -f pdf AsymptoteFileName.asy
 * 21) Or you can incorporate the code into a LaTeX document, say interactivePdf3D.tex by including the asymptote package in its preamble and then create an asymptote environment, where you can copy the generated Asymptote code or include the file AsymptoteFilename.asy:

or


 * 1) Compile the files with the following command lines:


 * 1) At this point there will be a pdf-3D file: interactivePdf3D.pdf
 * 2) When reading it with Acrobat Reader, you will have the option of trusting the file once or always. If you agree to trust the file, after a click, you will be able to interact with the figure. You will be able to rotating it, moving it horizontally and vertically, as well as being able to zoom in or out.