Tuesday, October 29, 2013

AutoLISP Program For Drawing A Cabinet 13

This AutoLISP Program


This AutoLISP program is an example of what can be done if you are working with an AutoLISP program. An AutoLISP program makes AutoCAD very fast.


You have seen how quickly the AutoCAD drawing was created. It started with a dialog box. And the dialog box had to be filled in.


So because of the dialog box more time was need to create the AutoCAD drawing. But it was done in less than ten seconds.


Could you create the drawing of the cabinet in less than ten seconds if you would do it by hand? I don't think so.


Complete AutoCAD Drawings


You know. That can be done with an AutoLISP program. You can create a part of an AutoCAD drawing with it or a complete drawing.


You have seen that now. If an AutoLISP program is used for creating an AutoCAD drawing. It goes very fast. It is done in no time.


Sure. Maybe you are creating the same drawing all the time. But the sizes of the drawing change. No problem. Use a dialog box.


OK. You are working with AutoCAD. You know how it is. You must wait for hours before your AutoCAD drawing is created.


Advantages AutoLISP Program


And now you have seen. If you work with an AutoLISP program, then you have your AutoCAD drawing right away.


Working with an AutoLISP program has two more big advantages:


1. You don't need to check the drawing once is is finished. The AutoLISP program follows all the standards. So you use the drawing right away.


2. Now you are working with AutoCAD operators. Who else can create AutoCAD drawings? AutoLISP programs work without AutoCAD operators.


One Problem


Now you only have one problem. You want AutoLISP programs. You have seen how good they are. But you cannot write them.


If that is your problem. You could come to me. I could write an AutoLISP program for you. And you are not spending a lot of money.


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.
-------------------------------------------------


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.
-------------------------------------------------


Sunday, October 13, 2013

AutoLISP Program For Drawing A Cabinet 11




The Complete 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)
)


(defun clscr (/ ss)
(command "zoom" "extents")
(setq p1 (getvar "vsmin")
p2 (getvar "vsmax")
)
(setq ss (ssget "c" p1 p2))
(if ss
(command "erase" "all" "")
)
)


(defun getsz (/ di fl hi ls nr oh th wd wi)
(setq fl 0
wd 600
oh 50
th 25
)
(while (= fl 0)
(setq di (load_dialog "c:/make/cabin.dcl"))
(new_dialog "cabin" di)
(setq wi (dimx_tile "im")
hi (dimy_tile "im")
)
(start_image "im")
(fill_image 0 0 wi hi 0)
(slide_image -100 -100
(+ wi 100)
(+ hi 100)
"c:/make/cabin.sld"
)
(end_image)
(set_tile "wd" (itoa wd))
(set_tile "nr" "2")
(set_tile "oh" (itoa oh))
(set_tile "th" (itoa th))
(mode_tile "wd" 3)
(start_list "nr" 3)
(add_list "3")
(add_list "4")
(add_list "5")
(add_list "6")
(end_list)
(action_tile "accept" "(setq ls (value))
(done_dialog)")
(start_dialog)
(unload_dialog di)
(setq fl (nth 0 ls)
wd (nth 1 ls)
nr (nth 2 ls)
oh (nth 3 ls)
th (nth 4 ls)
)
)
(list wd nr oh th)
)


(defun value (/ fl nr oh th wd)
(setq wd (atoi (get_tile "wd"))
nr (atoi (get_tile "nr"))
oh (atoi (get_tile "oh"))
th (atoi (get_tile "th"))
)
(cond
((= nr 0)
(setq nr 3)
)
((= nr 1)
(setq nr 4)
)
((= nr 2)
(setq nr 5)
)
((= nr 3)
(setq nr 6)
)
)
(if (< wd 400)
(progn
(alert "Minimum width is 400")
(setq fl 0)
)
(setq fl 1)
)
(list fl wd nr oh th)
)


(defun drcab (pt wd nr)
(if (tblsearch "layer" "cabinet")
(command "layer" "s"
"cabinet"
""
)
(progn
(command "layer" "m"
"cabinet"
"c"
"green"
""
""
)
)
)
(command "line" pt
(setq pt (polar pt 0 wd))
(setq pt (polar pt
(* pi 0.5)
(+ (* nr
(+ 100
25
)
)
25
)
)
)
(setq pt (polar pt pi wd))
"c"
)
)


(defun drtop (pt wd nr oh th)
(command "line" (setq pt (polar pt
(* pi 0.5)
(+ (* nr
(+ 100 25)
)
25
)
)
)
(setq pt (polar pt pi oh))
(setq pt (polar pt (* pi 0.5)
th
)
)
(setq pt (polar pt
0
(+ wd
(* oh 2)
)
)
)
(setq pt (polar pt
(* pi 1.5)
th
)
)
(polar pt pi oh)
""
)
)


(defun drdrw (pt wd nr)
(repeat nr
(command "line" (setq pt (polar pt 0 25)
pt (polar pt
(* pi 0.5)
25
)
)
(setq pt (polar pt
0
(- wd 50)
)
)
(setq pt (polar pt
(* pi 0.5)
100)
)
(setq pt (polar pt
pi
(- wd 50)
)
)
"c"
(setq pt (polar pt pi 25))
)
)
)


(defun drhnd (pt wd nr / e1 e2)
(setq pt (polar pt 0 175)
pt (polar pt (* pi 0.5) 65)
)
(repeat nr
(command "line" pt
(polar pt 0 (- wd 350))
""
)
(setq e1 (entlast))
(setq pt (polar pt (* pi 0.5) 20))
(command "line" pt
(polar pt 0 (- wd 350))
""
)
(setq e2 (entlast))
(drarc e1 e2)
(setq pt (polar pt (* pi 0.5) 105))
)
)


(defun drarc (e1 e2 / el p1 p2 p3 p4)
(command "fillet" e1 e2)
(setq el (entget e1)
p1 (cdr (assoc 10 el))
p2 (cdr (assoc 11 el))
el (entget e2)
p3 (cdr (assoc 10 el))
p4 (cdr (assoc 11 el))
)
(command "erase" e1 e2 "")
(command "line" p2 p1 "")
(setq e1 (entlast))
(command "line" p4 p3 "")
(setq e2 (entlast))
(command "fillet" e1 e2)
)


(defun setdm ()
(command "-style"
"dimension"
"courier new"
0
1
0
"no"
"no"
)
(if (tblsearch "layer" "dimension")
(command "layer" "s"
"dimension"
""
)
(progn
(command "layer" "m"
"dimension"
"c"
"red"
""
""
)
)
)
(setvar "dimasz" 10)
(setvar "dimcen" 10)
(setvar "dimclrt" 2)
(setvar "dimdec" 0)
(setvar "dimdli" 5)
(setvar "dimexe" 5)
(setvar "dimexo" 5)
(setvar "dimgap" 5)
(setvar "dimtad" 1)
(setvar "dimtdec" 0)
(setvar "dimtih" 0)
(setvar "dimtoh" 0)
(setvar "dimtvp" 5)
(setvar "dimtxsty" "dimension")
(setvar "dimtxt" 10)
)


(defun drdim (pt wd nr oh th)
(command "dimlinear" pt
(setq pt (polar pt 0 wd))
(polar pt (* pi 1.5) 35)
)
(command "dimlinear" pt
(setq pt (polar pt
(* pi 0.5)
(+ (* nr
125
)
25
)
)
pt (polar pt 0 oh)
)
(polar pt 0 35)
)
(command "dimlinear" pt
(polar pt (* pi 0.5) th)
(polar pt 0 35)
)
(setq pt (list 0 0))
(command "dimlinear" (setq pt (polar pt
(* pi 0.5)
(+ (* nr
125
)
25
)
)
)
(polar pt pi oh)
(polar pt (* pi 1.5) 35)
)
)




(c:cabin)


13 Posts Now


This post is very long. Still. There is a lot more that I want to say. I want to say something about:


1. Programming in AutoLISP
2. This AutoLISP Program


I will do it in two separate posts. Sorry. In the beginning I was saying that this series only has 11 posts. That is now 13 posts.


Next Post


In the next post I'm going to talk about programing in AutoLISP.




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:


Make AutoCAD Fast
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


Tuesday, October 8, 2013

AutoLISP Program For Drawing A Cabinet 10

AutoLISP Program For Drawing A Cabinet 10


Dimensioning The Drawing


We have drawn the cabinet. We have drawn the cabinet, the top of the cabinet, the drawers and the handles of the drawers.


The DRDIM Function


Now we are going to add the dimensions to the drawing. See the DRDIN function. That function is used for adding the dimensions


(defun drdim (pt wd nr oh th)
(command "dimlinear" pt
(setq pt (polar pt 0 wd))
(polar pt (* pi 1.5) 35)
)
(command "dimlinear" pt
(setq pt (polar pt
(* pi 0.5)
(+ (* nr
125
)
25
)
)
pt (polar pt 0 oh)
)
(polar pt 0 35)
)
(command "dimlinear" pt
(polar pt (* pi 0.5) th)
(polar pt 0 35)
)
(setq pt (list 0 0))
(command "dimlinear" (setq pt (polar pt
(* pi 0.5)
(+ (* nr
125
)
25
)
)
)
(polar pt pi oh)
(polar pt (* pi 1.5) 35)
)
)


How The DRDIM Function Works


That is not too complicated. We have set the dimension variables in the previous function. So we can add the dimensions.


It is all a matter of calculating where the points of the dimensions are. And using the DIMLINEAR command.


That is important. The dimensions are drawn on a distance that is 35 from the points that were picked first.


I feel you understand how the DRDIM function works. If you have any questions. Add a comment to this post.


I will see your comment and give an answer to your question. I will help you to get a better understanding of the function.


Next Posts


In the next posts I'm going to give you the complete AutoLISP program. I will also talk about how AutoLISP programming is done.


And I have a post that is about my business. It is about Make AutoCAD Fast. I will tell you what I or my business could do for you.


Telling Others


Do you like what you have read? Do you know other people, that also could be interested in what I'm saying? 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.


YouTube


I have added videos to YouTube. The videos give examples of my AutoLISP programming work. You could engage me if you want.


If you are thinking of engaging me. Listen. I work for free. I write an AutoLISP program for you. You only pay when you are satisfied.


That is important. When you come to me with an AutoLISP programming job, you are not spending any money.


On YouTube you can find my videos here:


http://youtu.be/zgTWKo7DpeM
http://youtu.be/sd-sbyM3-d8
http://youtu.be/2yhk7G5KlAs
http://youtu.be/mEA6lymElqI
http://youtu.be/eyOdOTHPH-o
http://youtu.be/O8Zy6n9zS8Q
http://youtu.be/5sMBtfnnizk
http://youtu.be/QrmbXvmFa2o
http://youtu.be/4Ol-YpDC2MY

http://youtu.be/DWFke-Nie0E