Saturday, September 21, 2013

AutoLISP Program For Drawing A Cabinet 8


Drawing The Handles


We have drawn the cabinet. We have drawn the top of the cabinet. And we have drawn the drawers. But the drawers have handles.


How The Two Functions Work


There are two functions for drawing the handles. We have the DRHND function and the DRARC fucntion. Let me explain why.


In the DRHND function two lines are drawn on a drawer. But at the end of the lines are arcs. How do we get arcs there?


The arcs are drawn using the FILLET command. Thart is done in the DRARC function. But we have a complication.


When the FILLET command is used on tow parallel lines, then an arc is drawn between the lines. It is an arc of 180 degrees.


Except. The arc is drawn on the side of the lines where the starting points of the lines can be found. So only one arc is drawn.


To have an arc drawn on the other side of the lines, the lines have to be erased and drawn again. And the FILLET command is used again.


The two lines are given to the DRARC function. The FILLET command is performed. Next the two lines are erased and drawn again.


When the lines are drawn again, they are drawn in the opposite direction. So the position of the starting points change.


The FILLET command is performed again. And now the arcs are on the opposite side of the two lines. Now we have a handle.


The Two Functions


(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)
)


Next Posts


I hope everything was clear. If not. Let me know by adding a comment to this post. If you do, I will come back to you and give an answer.


In the next two posts I'm going to talk about dimensioning the cabinet. We have tow functions for doing that.




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



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


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


makeautocadfast@ymail.com


No comments:

Post a Comment