For a fixed viewpoint, you can use BoundaryDiscretizeRegion
with the option MeshCellStyle
to style individual line primitives:
pyramid = Pyramid[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {0, 0, 2}}];
Show[BoundaryDiscretizeRegion[pyramid ,
MaxCellMeasure -> Infinity,
PlotTheme -> "Lines",
MeshCellStyle -> {{1, 4|5|8} -> Directive[Black, Dashing[Large]], {1, _} -> Black},
MeshCellLabel -> MapThread[{0, #} -> Placed[Style[#2, 16, Bold], #3] &,
{Range @ 5, {"C", "D", " B", "A ", "S"}, {Below, Below, After, Before, Above}}],
ViewPoint -> {.1, -3, 1}]] /. {_Line} :> {}

Update:
We can use a slight modification of the function DashedGraphics3D
from this answer by Silvia to get a 2D image of Graphics3D
object with lines behind the front surface rendered as dashed lines. The only changes I made in the function are to add Pyramid
in the list of 3D primitives,
face3DPrimitives = {Pyramid, Cuboid, Cone, Cylinder, Sphere, Tube,
BSplineSurface}
and replace Dashed
with Dashing[Large]
:
Examples:
SeedRandom[7]
Grid[Transpose @ Table[
{Graphics3D[{FaceForm[Directive[[email protected], LightBlue]],
EdgeForm[Thick], pyramid},
Boxed -> False, ViewPoint -> v,
ImageSize -> 400, SphericalRegion -> True,
PlotLabel -> PromptForm[Style["view point", 16], Style[v, 16]]],
Show[DashedGraphics3D[Graphics3D[pyramid, Boxed -> False],
ViewPoint -> v, ImagePadding -> 120], ImageSize -> 300]},
{v, Round[ RandomReal[{-2, 3}, {4, 3}], .01]}],
Spacings -> {1, 1}]
