Icosahedron

screenshot_2-24-2016_8

The Icosahedron is one of 5 Platonic solids. It has 12 vertices and 20 faces. The point coordinates are worked out and given in wikipedia.

Type the coordinates into a spreadsheet to work with them.

.
.
.
.
.

screenshot_2-24-2016_5

screenshot_2-24-2016_6

The program creates a labeled point object in autocad. This just to visualize the vertices and help to write the code for the faces. I like the point names to make sense, i manipulated these by quadrant and z value. Having a 3D mouse helps. I manually made the positive Z values a different color from those at Z = 0 and negative Z just for visibility.
screenshot_2-24-2016_7

screenshot_2-24-2016_2

screenshot_2-24-2016_3

screenshot_2-24-2016_4

Once the 12 points are settled in their quadrants and elevations, 20 Acad3DFace statements have to be written. Again a 3D mouse comes in handy. Looking at the points, open a picture of an Icosahedron for reference, and write down point numbers to connect as triangles. Keep them in groups. Test them periodically, top half, bottom half, etc.

Sub icosahedron()
'12 vertices and 20 faces
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

Call initpt(pt1, 0, 1, p)
Call initpt(pt2, 0, -1, p)
Call initpt(pt3, p, 0, 1)
Call initpt(pt4, -p, 0, 1)

Call initpt(pt5, 1, p, 0)
Call initpt(pt6, -1, p, 0)
Call initpt(pt7, -1, -p, 0)
Call initpt(pt8, 1, -p, 0)

Call initpt(pt9, p, 0, -1)
Call initpt(pt10, -p, 0, -1)
Call initpt(pt11, 0, 1, -p)
Call initpt(pt12, 0, -1, -p)

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")

'creates 3DFace
Dim objent As Acad3DFace
'Top half
Set objent = acadDoc.ModelSpace.Add3DFace(pt1, pt2, pt3, pt3)
Set objent = acadDoc.ModelSpace.Add3DFace(pt1, pt2, pt4, pt4)

Set objent = acadDoc.ModelSpace.Add3DFace(pt2, pt3, pt8, pt8)
Set objent = acadDoc.ModelSpace.Add3DFace(pt2, pt7, pt8, pt8)
Set objent = acadDoc.ModelSpace.Add3DFace(pt2, pt4, pt7, pt7)

Set objent = acadDoc.ModelSpace.Add3DFace(pt1, pt3, pt5, pt5)
Set objent = acadDoc.ModelSpace.Add3DFace(pt1, pt5, pt6, pt6)
Set objent = acadDoc.ModelSpace.Add3DFace(pt1, pt4, pt6, pt6)

'bottom half
Set objent = acadDoc.ModelSpace.Add3DFace(pt9, pt11, pt12, pt12)
Set objent = acadDoc.ModelSpace.Add3DFace(pt10, pt11, pt12, pt12)

Set objent = acadDoc.ModelSpace.Add3DFace(pt5, pt6, pt11, pt11)
Set objent = acadDoc.ModelSpace.Add3DFace(pt5, pt9, pt11, pt11)
Set objent = acadDoc.ModelSpace.Add3DFace(pt6, pt10, pt11, pt11)

Set objent = acadDoc.ModelSpace.Add3DFace(pt7, pt8, pt12, pt12)
Set objent = acadDoc.ModelSpace.Add3DFace(pt7, pt10, pt12, pt12)
Set objent = acadDoc.ModelSpace.Add3DFace(pt8, pt9, pt12, pt12)

'ends
Set objent = acadDoc.ModelSpace.Add3DFace(pt3, pt5, pt9, pt9)
Set objent = acadDoc.ModelSpace.Add3DFace(pt3, pt8, pt9, pt9)

Set objent = acadDoc.ModelSpace.Add3DFace(pt4, pt6, pt10, pt10)
Set objent = acadDoc.ModelSpace.Add3DFace(pt4, pt7, pt10, pt10)

objent.Update
End Sub

the autocad vba Add3DFace method has a slight error in its documentation. It states the 4th argument is optional, for drawing 3 sided figures, but I don’t find that to be true. However if the 3rd point is repeated, it will draw a triangle

screenshot_2-24-2016_1

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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