#### Irregular Angles

*I* know I planned on only having a circle, rectangle and hexagon as options in my autolisp function for isometric drawing, but just after I finished with my code I realized I needed one more thing: a way to create irregular angles on the face of an axis. This makes it much easier to build complex geometry in isometric views, and it wasnâ€™t actually too difficult to implement once I figured out some of the mechanisms.

#### Building Geometry

*The* first thing to do is determine the angle transformation from regular to isometric. The relative position of the angle remains constant in the transformation (a 45 degree angle still goes to the opposite corner of a cube). This means that:

theta/90 = phi/60,

*Where* theta is the angle at 90 degrees and phi is the angle at 60 degrees. Thereby theta * 60/90 is equal to the transformation angle. We then add that angle to the additional 30 degrees created by the isometric view (figure 1). The line can then be divided into x and y coordinates using trig functions, as seen from the code below:

(setq m1(getdist "\n Length(inches):")) ;query magnitude

(setq r2(getangle "\n Angle:")) ;query angle

(setq f1(getstring "\n Face(Top/Left/Right):"))

(cond

((or (= f1 "L") (= f1 "l") (= f1 "Left") (= f1 "left") (= f1 "LEFT")) (progn

(setq i -1.0)

(setq r3 (* r2 (/ 60.0 90.0))) ) )

((or (= f1 "R") (= f1 "r") (= f1 "Right") (= f1 "right") (= f1 "RIGHT"))

(progn

(setq i 1.0)

(setq r3 (* r2 (/ 60.0 90.0))) ) )

((or (= f1 "T") (= f1 "t") (= f1 "Top") (= f1 "top") (= f1 "TOP"))

(progn

(setq i 1.0)

(setq r3 (* r2 (/ 120.0 90.0))) ) )

)

(setq pta1 (list (+ x1 (* i (* m1 (cos (+ a1 r3))))) (+ y1 (* m1 (sin (+ a1 r3)))) 0)) (command "._line" pt1 pta1 "")

*And* there you have it! I hope you enjoyed this bonus post about AutoLISP. I may create a data or geographic information systems (GIS) themed script in the future, depending on how much I can get out of the built-in features in AutoCAD and how useful Autocad would be for those purposes.

Tags: AutoCAD, AutoLISP, LISP