The Dodecahedron has 20 vertices and 12 faces. The face is a pentagon with 5 vertices. There are 5 Platonic solids. The face of the cube has 4 vertices, a square, the remaining solids, the tetrahedron, the octahedron and the icosahedron, each have a face with 3 vertices. For those first 4 solids i used the Autocad 3DFace object. It takes an argument list of 4 points. It can draw either a 4 sided figure, or a 3 sided figure by duplicating the last two points, and that is all. The “Autocad 2011 Quick Reference” by Ralph Grabowski says the 3DFace object was added to the program all the way back in V2.6. That was 1986! Autodesk programmers have moved on. They have over time added Solids, Surfaces and Meshes, but I do not see an object like 3DFace that can draw a polygon in 3D space. Add3DMesh is intended to be rectangular. AddPolyFaceMesh can do it, but it has the same 4 point limit. two co-planar faces have to be created, one of them quadrilateral the other triangular. It could be made to work, but its not elegant and there are potentially many many-sided figures we may want to draw. A Region could be drawn then extruded to a very thin solid, such as .001, but that’s not elegant either. The old 3DFace object is designed like an Euclidean plane, with defined edges and no thickness.

The Region object by itself is what we want, paired with a 3D Polyline to define it. I made a subroutine dedicated to drawing pentagons in 3D space given the 5 vertices.

First we compute the vertices xyz coordinates and put them into a spreadsheet. next the data is manually sorted by descending Z value and by quadrant, just to give it a little geometric order on the screen. we get the formula from wikipedia.



Sub dodecahedron()
'12 faces and 20 vertices
Call connect_acad

'create phi
Dim p As Double
p = 1.6180339887

Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double
Dim pt3(0 To 2) As Double
Dim pt4(0 To 2) As Double
Dim pt5(0 To 2) As Double
Dim pt6(0 To 2) As Double
Dim pt7(0 To 2) As Double
Dim pt8(0 To 2) As Double
Dim pt9(0 To 2) As Double
Dim pt10(0 To 2) As Double
Dim pt11(0 To 2) As Double
Dim pt12(0 To 2) As Double
Dim pt13(0 To 2) As Double
Dim pt14(0 To 2) As Double
Dim pt15(0 To 2) As Double
Dim pt16(0 To 2) As Double
Dim pt17(0 To 2) As Double
Dim pt18(0 To 2) As Double
Dim pt19(0 To 2) As Double
Dim pt20(0 To 2) As Double

Call initpt(pt1, 0, 1 / p, p)
Call initpt(pt2, 0, -1 / p, p)
Call initpt(pt3, 1, 1, 1)
Call initpt(pt4, -1, 1, 1)
Call initpt(pt5, -1, -1, 1)
Call initpt(pt6, 1, -1, 1)
Call initpt(pt7, p, 0, 1 / p)
Call initpt(pt8, -p, 0, 1 / p)
Call initpt(pt9, 1 / p, p, 0)
Call initpt(pt10, -1 / p, p, 0)
Call initpt(pt11, -1 / p, -p, 0)
Call initpt(pt12, 1 / p, -p, 0)
Call initpt(pt13, p, 0, -1 / p)
Call initpt(pt14, -p, 0, -1 / p)
Call initpt(pt15, 1, 1, -1)
Call initpt(pt16, -1, 1, -1)
Call initpt(pt17, -1, -1, -1)
Call initpt(pt18, 1, -1, -1)
Call initpt(pt19, 0, 1 / p, -p)
Call initpt(pt20, 0, -1 / p, -p)

'drawing and labeling points is not required in the finish program
'but is almost essential for deciding
'which points are the vertices for which faces
Call point(pt1, "pt1")
Call point(pt2, "pt2")
Call point(pt3, "pt3")
Call point(pt4, "pt4")
Call point(pt5, "pt5")
Call point(pt6, "pt6")
Call point(pt7, "pt7")
Call point(pt8, "pt8")
Call point(pt9, "pt9")
Call point(pt10, "pt10")
Call point(pt11, "pt11")
Call point(pt12, "pt12")
Call point(pt13, "pt13")
Call point(pt14, "pt14")
Call point(pt15, "pt15")
Call point(pt16, "pt16")
Call point(pt17, "pt17")
Call point(pt18, "pt18")
Call point(pt19, "pt19")
Call point(pt20, "pt20")

  Call draw_pentagon(pt1, pt2, pt6, pt7, pt3)
  Call draw_pentagon(pt1, pt2, pt5, pt8, pt4)
  Call draw_pentagon(pt1, pt3, pt9, pt10, pt4)
  Call draw_pentagon(pt2, pt6, pt12, pt11, pt5)
  Call draw_pentagon(pt6, pt7, pt13, pt18, pt12)
  Call draw_pentagon(pt3, pt9, pt15, pt13, pt7)
  Call draw_pentagon(pt5, pt11, pt17, pt14, pt8)
  Call draw_pentagon(pt11, pt12, pt18, pt20, pt17)
  Call draw_pentagon(pt4, pt8, pt14, pt16, pt10)
  Call draw_pentagon(pt9, pt10, pt16, pt19, pt15)
  Call draw_pentagon(pt13, pt15, pt19, pt20, pt18)
  Call draw_pentagon(pt16, pt14, pt17, pt20, pt19)

End Sub

Sub draw_pentagon(pt1() As Double, pt2() As Double, pt3() As Double, pt4() As Double, pt5() As Double)
Dim polyobj As Acad3DPolyline
Dim entarray(0) As AcadEntity
Dim regionObj As Variant
Dim vtx(0 To 14) As Double

    vtx(0) = pt1(0): vtx(1) = pt1(1): vtx(2) = pt1(2)
    vtx(3) = pt2(0): vtx(4) = pt2(1): vtx(5) = pt2(2)
    vtx(6) = pt3(0): vtx(7) = pt3(1): vtx(8) = pt3(2)
    vtx(9) = pt4(0): vtx(10) = pt4(1): vtx(11) = pt4(2)
    vtx(12) = pt5(0): vtx(13) = pt5(1): vtx(14) = pt5(2)

    '3D polyline takes an array of doubles
    Set polyobj = acadDoc.ModelSpace.Add3DPoly(vtx)
    polyobj.Closed = True

    'addregion takes an array of autocad entities
    'in this case an array of one entity
    Set entarray(0) = polyobj
    regionObj = acadDoc.ModelSpace.AddRegion(entarray)
End Sub

Sub initpt(ByRef ptn() As Double, val1, val2, val3)
ptn(0) = val1: ptn(1) = val2: ptn(2) = val3
End Sub



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s