|Posted by Eamon Kelly on August 5, 2010 at 1:26 PM|
So lately I've been working in AutoCAD and have starting learning both it and the programming language it uses, AutoLISP. First, I'll clarify the title of this post by explaining a little bit about LISP. LISP actually stands for LISt Processing becuase it uses lists as a data structure. It has been dubbed "lost in stupid parentheses" because everything needs to be enclosed in parentheses. For example, to add 1 and 1, you would write (+ 1 1). You'll notice the other thing that can be a pain in LISP is that operators (addition, subtraction, etc) come first. This isn't a problem when you've only got one operation occurring, but quickly becomes a nightmare once you attempt multiple operations at once. For example, (+ (- (/ 6 2) (* 1 8 ) ) 7) will divide 6 by 2, subtract the multiplication of 8 and 1 from that, and then add seven. Because of the parentheses, it is easy to make mistakes and become lost.
But enough complaining. The cool thing about LISP is that it can be used to execute commands in AutoCAD. Instead of clicking the 'line' button, and then specifying two points, I can use code to virtually click the line button and draw a line from two data points, instead of doing it manually with my hand and mouse. Drawing lines is also the focus of this post. I have written a couple programs that draw bents (the vertical support structures placed along the direction of travel in wooden roller coasters) as a bunch of lines. The first program I wrote asks for a height, and then draws the bent.
The box is called Dialog Control Language, and can be used in LISP to make, well, boxes. I messed around with it a little but probably won't get into it unless I make one for the final program. When I hit okay, I get the following:
So as you can see, it will automatically draw me a bent of whatever height I need. Next I added in the ability to draw multiple bents, where the program asks for how many the user needs, and then just runs through the bentgen code that many times, increasing the y values to space the bents out. After that, I decided to try and pull data from my MatLab code to start making something that resembles a coaster. I am still working out a lot of kinks, but I did manage to get it to draw up all the bents for the lift hill from the previous post's MatLab code. Here is a video of the resulting lines:
As you can see, it actually looks like the structure of a wooden roller coaster. As I said, I will continue to go through and do most of what the final code will be with just lines, including batters (sloped supports) and other elements of the structure, pulling data from my MatLab code. This will help me learn better how to use AutoCAD and AutoLISP and the resulting code will allow me to quickly visualize my layouts from MatLab. That is all for now, but look forward to learning more about getting lost in parentheses... it's pretty much a given at this point that it will happen a lot.
Categories: Roller Coaster Design Project