#### The Hexagon

*The* hexagon is a little more complicated of a shape than a rectangle. Since it has geometry directly perpendicular to one axis, it becomes trivial to use more trigonometry to solve for the points.

#### Developing the Geometry

*Like* placing any other geometry, you need a reference point, which we’ll set as the center of the hexagon to be drawn. We then have to find out what size of hexagon to draw, using the radius of the circle inscribed inside the hexagon (figure 1).

*We* then use the radius provided to build the geometry directly on the isometric x-y axes, and then build the geometry between those points:

(setq t1(getdist "\n Trade Size Width(inches):"))

(setq r1 (/ t1 (sin (* a1 2))))

(setq s1 (* r1 (cos (* a1 2))))

(setq pthx1 (list (+ x1 (+ (* (/ t1 2) (cos a3)) (* (/ s1 2) (cos a4)))) (+ y1 (+ (* (/ t1 2) (sin a3)) (* (/ s1 2) (sin a4)))) 0))

(setq pthx2 (list (+ x1 (+ (* (/ t1 2) (cos a3)) (* (/ s1 2) (cos a2)))) (+ y1 (+ (* (/ t1 2) (sin a3)) (* (/ s1 2) (sin a2)))) 0))

(setq pthx3 (list (+ x1 (* (/ r1 2) (cos a2))) (+ y1 (* (/ r1 2) (sin a2))) 0))

(setq pthx4 (list (+ x1 (+ (* (/ t1 2) (cos a1)) (* (/ s1 2) (cos a2)))) (+ y1 (+ (* (/ t1 2) (sin a1)) (* (/ s1 2) (sin a2)))) 0))

(setq pthx5 (list (+ x1 (+ (* (/ t1 2) (cos a1)) (* (/ s1 2) (cos a4)))) (+ y1 (+ (* (/ t1 2) (sin a1)) (* (/ s1 2) (sin a4)))) 0))

(setq pthx6 (list (+ x1 (* (/ r1 2) (cos a4))) (+ y1 (* (/ r1 2) (sin a4))) 0))

(command "._pline" pthx1 pthx2 pthx3 pthx4 pthx5 pthx6 "C")

Now that that’s taken care of, on to the hard one, the circle!

Tags: AutoCAD, AutoLISP, LISP