Friday, September 27, 2013

AutoLISP Program For Drawing A Cabinet 9


Setting The Dimension Variables


We want to add dimensions to the cabinet drawing. But before we can do that, we need to set the dimension variables.


The AutoLISP Function


Here is the function for setting the dimension variables. More is done. Something is done with text and something with layer.


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


How The Function Works


We want to use the font COURIER NEW for the dimensions. That is why we create a text style with that font first.


Do you see? As we invoked the command, we specified for the name of the command “-STYLE”. That is done to have prompts.


If we would specify the name of the command as “STYLE”, then a dialog box would have been displayed. We don't want that.


Bext we want to set the DIMENSION LAYER as the default layer. We want the dimensions being drawn on that layer.


The TBLSEARCH function is used to see whether the DIMENSION layer is there. If so it is set. If not the layer is created.


Now we come to all the system variables for the dimensions. How could we find all the values for the dimension variables?


Easy. Set the dimension style. And once the dimension style has been set. Check the value of all dimension system variables.


Enter SETVAR at the command prompt. The following two prompts show up:


Variable name or ? :
Variable(s) to list <*>:


At the first prompt enter “?”. At the second promkpt enter “dim*”.


A list of all system variables with a name that starts with DIM is displayed. You can copy that list. And use it for the function.


The list is very long. You don't need all the system variables. You can see in the function what system variables are important.


Next Post


You have seen how all the system variables for the dimensions are set. Now we can go to drawing all the dimensions. That is in my next post.


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


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


Friday, September 20, 2013

AutoLISP Program For Drawing A Cabinet 7

The Drawers


Before we draw the drawers. I must tell you about the drawers. I must tell you about the sizes of the drawers, related to the width.


See the picture. The height of each drawer is 100. And below and above each drawer is a distance of 25.


The width of the drawer. The distance between a drawer and the side of the cabinet is 125. So the width is 250 less than the width of the cabinet.




The Function For Drawing The Drawers


Here is the function for drawing the drawers.


(defun drcab (pt wd nr)
(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"
)
)


For starters we create the CABINET layer. The color of the layer is green. So what is drawn on it, gets the color green.


Next we can draw a rectangle. The rectangle starts in the base pointy. We have set the base point as being the point 0,0.


That is important. The height of the cabinet. It is like this. Each drawer has got a height of 100. And on each side is a length of 25.


For drawing the height of the cabinet we must make a calculation. The height is the number of drawers times 100 plus 25.


Above the drawers is an additional length of 25. So after the calculation is made 25 is added to the length that has been found.


The Next Post


We have drawn the drawers. Now we can draw the handles and the dimensions. I'm going to talk about it in the next posts.




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


Monday, September 9, 2013

AutoLISP Program For Drawing A Cabinet 6


Drawing The Top


We have drawn the cabinet. Now we want to draw the top of the cabinet. We have entered the thickness of the top and we have entered the overhang.


The AutoLISP Function


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


For drawing the top of the cabinet we need the base point, the width of the cabinet, the number of drawers, the overhang, and the thickness.


That information is given to the function by the main AutoLISP program. Now the top of the cabinet can be drawn.


The start point of the top is calculated. And then the top of the cabinet is drawn using the LINE command.


How the function works. It is pretty clear. I don't think I need to give an extra explanation. Do you agree with me?


If you don't agree and you want an extra explanation. Let me know. Add a comment to this post. And I'll come back to you.


Next Post


In the next post I'm going to talk about drawing then drawers. The cabinet has got drawers. So we need to draw them.


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






Monday, September 2, 2013

AutoLISP Program For Drawing A Cabinet 5

The Function For Drawing The Cabinet


Here is the function for drawing the cabinet. The cabinet is drawn on the CABINET layer. That layer is made active by the fucntion.


It works like this. Using the TBLSEARCH function there is checked if the layer exist. If not it is created. If it exists, there is switched to it.


Next four lines are drawn on the CABINET layer. The width of the cabinet is known. For the height a calcification must be made.


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


The Next Posts


We have drawn the cabinet. Now we can draw the rest of the cabinet: the drawers, the top, the handles, and the dimensions.


I'm going to talk about it in the next posts.


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




Sunday, September 1, 2013

AutoLISP Program For Drawing A Cabinet 4


Getting The Sizes 2


The AutoLISP programs has got two functions for getting the sizes of the cabinet, that we want. These functions are GETSZ and VALUE.


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


The GETSZ Function


In the GETSZ function we start with setting the base values. Those values are:


fl - flag
wd - width of the cabinet
nr - number of drawers
oh - overhang
th - thickness of the top


You can see what values have been given to the variables. Next we go into a WHILE loop. We stay there as long as the FL variable is 0.


In the WHILE loop we load the DCL file and we display the dialog box. The base values are given to the tiles of the dialog box.


The user can enter values in the edit boxes, When he clicks on the OK button, then the values are evaluated. There is seen what has been entered.


The VALUE Function


That is done in the VALUE function. The value of the popup list is checked with a COND function. See how it is done.


That is important. If the first choice is selected, then the popup list gives back zero. One is given back for the second choice. Etc.


Next there is the value of the width variable checked. If it is smaller than 400, then a warning dialog box is displayed.


In the dialog box is said that the minimum width is 400. The FL variable gets the value zero. The user gets a second chance to enter the width.


If the value of the width is 400 or more, then the FL variable gets the value 1. And there is jumped out of the WHILE loop.


All the values are given back to the GETSZ function.


The DCL File


We need to talk about the DCL file. Here it is:


cabin:dialog
{
label="Cabinet";
:boxed_column
{
:image
{
height=30;
width=80;
key="im";
}
spacer_1;
}
spacer_1;
: boxed_column
{
width = 25;
fixed_width=true;
alignment="centered";
: edit_box
{
key = "wd";
label = "Width:";
edit_width = 5;
initial_focus = true;
}
:popup_list
{
key = "nr";
label = "Drawers:";
edit_width = 1;
value = "";
}
: edit_box
{
key = "oh";
label = "Overhang:";
edit_width = 5;
}
: edit_box
{
key = "th";
label = "Thickness top:";
edit_width = 5;
}
spacer_1;
}
spacer_1;
ok_only;
}


I'm not going to say much about it. I guess it is clear what is done with the DCL file. Tiles are specified in the DCL file.


Next Post



In the next post I'm going to talk about drawing the cabinet. We have all the sizes that we need. So we can draw it.