Consider the MWE given below:

import graph3;
path3 bottom = (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
draw(extrude(bottom, 5*Z), white);

This generates a solid with surfaces (see the first picture below). Is there a way to mark the edges of the generated surface with lines automatically (see the second picture below)?

I can draw the bottom and top surface lines using regular draw, but I am wondering if I can draw the edges of the extruded surface automatically.

enter image description here

  • The extrude command is amazing ^^
    – Black Mild
    Jan 5, 2021 at 19:21

1 Answer 1


I see the syntax of the extrude command in three_surface.asy. Mathematicaly, with 3D paths p and q, the extrude command pushes the curve p along the orbit q.

surface extrude(path3 p, path3 q)
  static patch[] allocate;
  return surface(...sequence(new patch(int i) {
        return patch(subpath(p,i,i+1)--subpath(q,i+1,i)--cycle);

surface extrude(path3 p, triple axis=Z)
  return extrude(p,shift(axis)*p);

surface extrude(path p, triple plane(pair)=XYplane, triple axis=Z)
  return extrude(path3(p,plane),axis);

surface extrude(explicit path[] p, triple axis=Z)
  surface s;
  for(path g:p)
  return s;

We should not expect that edges of the extruded surface can be drawn automatically, simply because no edge is realized in the command extrude(path3 p, path3 q). For example, if q is a circle, then there is no edge at all.

enter image description here

// nice to rotate it on http://asymptote.ualberta.ca/
import graph3;
//path3 bottom = (0,0,0) -- (1,0,0) -- (1,1,0) -- (0,1,0) -- cycle;
path3 bottom=circle(O, 1, normal=Z);

draw(extrude(bottom, 2*Z+2*Y), yellow);
draw(extrude(bottom, -2*Z+2*Y), orange);

I believe that extrude command is very useful when making scientific 3D shapes: slanted cube, pyramid, or tubes along an orbit of a differential equation, ....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .