Asymptote: Difference between revisions

From FreeCAD Documentation
(More editing... There were too many steps in the exporting paragraph. This is not a tutorial. Linking to the command reference should be enough.)
mNo edit summary
Line 22: Line 22:
# Press the {{Button|Save}} button.
# Press the {{Button|Save}} button.


==Generate a PDF file from Asymptote code==
==Generating a PDF file from Asymptote code==


In order to get a pdf-3d file using this method, some packages must or are recommended to be installed on your system:
In order to get a pdf-3d file using this method, some packages must or are recommended to be installed on your system:

Revision as of 19:31, 24 December 2020

This documentation is a work in progress. Please don't mark it as translatable since it will change in the next hours and days.

Description

Asymptote is a programming language for the creation of 2D and 3D computer graphics. Asymptote code can be included in a LaTeX document or used to generate PostScript, PDF, SVG, WebGL, and PRC files.

Interactive 3D PDF files created from Asymptote code require Acrobat Reader version 9 or higher. For other PDF files any PDF reader can be used.

Asymptote support was added in FreeCAD version 0.19.

Exporting

To generate Asymptote code do the following:

  1. Optionally assign colors to the faces of the object you want to export with the Part FaceColors command.
  2. Change to the Mesh Workbench.
  3. Create a mesh from the object with the Mesh FromPartShape command.
  4. Select the new mesh object.
  5. Invoke the Mesh Export command.
  6. Select the *.asy file format in the dialog box.
  7. Enter a filename.
  8. Press the Save button.

Generating a PDF file from Asymptote code

In order to get a pdf-3d file using this method, some packages must or are recommended to be installed on your system:

  • Needed: Asymptote compiler
  • Needed if you want to embed the interactive figure into a document: A LaTeX system, for example TeX Live
    • Very useful: An Integrated LaTeX Editing Environment, for example Kile or TeXstudio


  1. (People using a LaTeX GUI should configure it appropriately for compiling Asymptote code or LaTeX documents containning Asymptote code.)
  2. The Asymptote compiler is called asy.
  3. You can compile the generated file directly using the command line:
    $ asy -f pdf AsymptoteFileName.asy
    
  4. 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:
    \documentclass[a4paper,10pt]{article}
    ...
    \usepackage{asymptote}
    ...
    \begin{document}
    ...
    \begin{asy}
    Asymptote Code goes here
    \end{asy}
    ...
    \end{document}
    
    or
    \documentclass[a4paper,10pt]{article}
    ...
    \usepackage{asymptote}
    ...
    \begin{document}
    ...
    \begin{asy}
    include "AsymptoteFileName.asy";
    \end{asy}
    ...
    \end{document}
    
  5. Compile the files with the following command lines:
    $ pdflatex interactivePdf3D.tex
    $ asy interactivePdf3D-*.asy
    $ pdflatex interactivePdf3D.tex
    
  6. At this point there will be a pdf-3D file: interactivePdf3D.pdf
  7. 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 rotate it, to pan it, as well as being able to zoom it in or out.

Related Pages

Video tutorials

Related video tutorial

Related tutorials