Tuesday, October 29, 2013

Programming in AutoLISP

Programming in AutoLISP


For a lot of people programming is very complicated. And programming in AutoLISP is especially complicated.


I don't think that is true. I don't think programming in AutoLISP is complicated at all. If you know what to do.


Figure Out What To Do


That is the trick. You want an AutoLISP program. Before you start programming, figure out what the program is supposed to do.


Also know. Everything that you want can be done in AutoLISP. So there is no limit in what you can figure out.


What Needs To Be Done


We wanted an AutoLISP program for drawing a cabinet. This is what needed to be done:


- Make the screen empty if it is not empty
- Get the sizes of the cabinet
- Draw the cabinet
- Draw the top of the cabinet
- Draw the drawers of the cabinet
- Draw the handles of the drawers
- Draw the dimensions
- Show the whole cabinet


Very good. We have made a list of everything that needed to be done. And what needs to nbe done, is done with a function.


All The Functions


Here is a list of all the functions that can be found in the complete AutoLISP program.


(clscr)
(getsz)
(drcab pt wd nr)
(drtop pt wd nr oh th)
(drdrw pt wd nr)
(drhnd pt wd nr)
(setdm)
(drdim pt wd nr oh th)


There is no function for showing the complete drawing. The ZOOM command is used in the AutoLISP program for doing that.


The Main AutoLISP Program


Here is the main AutoLISP program:


(defun c:cabin (/ pt ls wd nr oh th)
(setvar "cmdecho" 0)
(clscr)
(setq pt (list 0 0)
ls (getsz)
wd (nth 0 ls)
nr (nth 1 ls)
oh (nth 2 ls)
th (nth 3 ls)
)
(drcab pt wd nr)
(drtop pt wd nr oh th)
(drdrw pt wd nr)
(drhnd pt wd nr)
(setdm)
(drdim pt wd nr oh th)
(command "zoom" "extents")
(command "zoom" "0.8x")
(setvar "cmdecho" 1)
(princ)
)


In the main program the CMDECHO system variable is set to zero. That is done so we have no echos from the AutoCAD commands.


AutoLISP Is Not Too Complicated


But do you see that writing an AutoLISP program is not too complicated. You just need to find out first what needs to be done.


In fact. I'm now talking about programming in AutoLISP. But what I said. It goes for programming in any computer language.


Writing the AutoLISP program in the way as I have explained has got a big advantage. The maintenance of the program is much easier.


Figure out what function needs to be changed. And next change that function. You don't have to go through the whole AutoLISP program.


I'm not sure who is reading my blog. That could very well be people that are doing AutoLISP programming. Well. I gave you a good tip.


Next Post


In the next post I'm going to talk about this program and how my business is involved.




Telling Others


Do you like what you have read? Do you know other people, that could be interested? Could you tell them about this blog?




Comment


In the mean time. If you have any questions. Or you want to tell me something. Feel free to add a comment to this blog.


I would love to hear from you. And when you come to me with a comment. I will give a reply to your question or remark.




Warning


Don't spend a lot of money on AutoCAD Light. It is only for creating 2D drawings and it doesn't support AutoLISP.


There is a very similar CAD program. And that is completely free. The name of the program? DraftSight.


How to get it? Do a search on Google for “download DraftSight”. And you will find where you can download the program.






Only Create Drawings


When your CAD operators don't create the borders of your drawings, a lot of time is saved. You get your drawings much faster.


I have created a program that does exactly that. An AutoCAD drawing has been created and the program draws a border around it.


If you want to see how the program works, go to YouTube. You'll find the working of the program here:


http://www.youtu.be/O8Zy6n9zS8Q


Now the AutoLISP program gives you the choice to select the size of your border. You can select A4, A3, A2, or A1.


Maybe you already know the size of the border of your drawing. Maybe all your drawings have the size A1. If so. Let me know.


That is important. The program finds the proper scale of your drawing. Or do you already know what the scale always is?


I can write the AutoLISP program that you want. The price? I will only charge you RM 600.-. That is less than US $ 200.-.






You are welcome to publish my article provided you include the resource box with links intact.




Resource Box


Jos van Doorn is an AutoLISP programmer and blogger. He is originally from Holland and now he lives in Malaysia.



He is the founder of the Make AutoCAD Fast business. Make AutoCAD Fast is writing AutoLISP programs for AutoCAD users.



Make AutoCAD Fast created an AutoLISP program for drawing a border around AutoCAD drawings. The program can be found on YouTube.
http://www.youtu.be/O8Zy6n9zS8Q



Jos is writing a blog. In it are AutoLISP programs with information and it is about Make AutoCAD Fast. You can find his blog here:


http://www.makeautocadfast.blogspot.com


Maybe you have a question. Or want to tell me something. You can contact me on this e-mail address:


makeautocadfast@ymail.com


This article may be freely reprinted or distributed in its entirety in any Ezine, newsletter, blog, or website. As long as the following resource box is added:


-------------------------------------------------
This article is written by Jos van Doorn. He is an AutoLISP programmer who has helped engineering firms and architects to get their AutoCAD drawings fast, without waiting for hours.


You can find more valuable information about his
business and AutoLISP at his blog. It is here:


http://www.makeautocadfast.blogspot.com


If you want to contact him. Go to his blog and leave a comment.
-------------------------------------------------


No comments:

Post a Comment