Showing posts with label Rectangle. Show all posts
Showing posts with label Rectangle. Show all posts

Thursday, November 7, 2013

Drawing A Rectangle With AutoLISP 6

Function 8, 9, and 10


Using these functions the dimensions are added to the rectangle, the scale of the drawing is written down, and the AutoLISP program ends.


Function 8


The dimension variables have been set in the seventh function. Now we can add the dimensions to the rectangle.


First the DIMENSION layer is set. And then the dimensions are drawn using the DIMLINEAR command. It is very straight forward.


The dimensions are drawn on a certain distance from the rectangle. We need the scale factor to calculate the distance.


(defun drdim (sc)
(command "layer" "s" "dimensions" "")
(command "dimlinear" p1
(polar p1 0 wd)
(polar p1
(* pi 1.5)
(* 20 sc)
)
)
(command "dimlinear" p2
(polar p2 (* pi 1.5) ht)
(polar p2 0 (* 20 sc))
)
)


Function 9


Now the scale factor needs to be written to the drawing. The TEXT command is used for doing that. It is pretty straight forward.


The TEXT layer is set. And then the position of the text for the scale is calculated. For that the scale factor is used.


That is the trick. With the text command we can only write text. But the scale factor is not a text. It is a real.


So we need to turn the scale factor into a text. That is done using the RTOS function. The number of decimals is set to zero.


(defun drscl (sc)
(command "layer" "s" "text" "")
(command "text" "r"
(setq pt
(polar (list 0 0)
0
(+ (* sc 10)
(* (- 400 10) sc
)
)
)
pt (polar pt
(* pi 0.5)
(* 20 sc)
)
)
(* 10 sc)
0
(strcat "Scale "
(rtos sc 2 0))
)
)


Function 10


Here is the last function of the AutoLISP program. I'm done with the AutoLISP program. Now I must end it.


First I zoom the drawing out. For doing that the ZOOM command is used. Firs the ALL option is used and then the factor 0.8.


At the beginning of the AutoLISP program, the CMDECHO system variable has been set to zero. Now it is set the one again.

(defun endpr ()
(command "zoom" "all")
(command “zoom” “0.8x”)
(setvar "cmdecho" 1)
(princ)
)


The Whole AutoLISP Program


You now have had the whole AutoLISP program. You can copy it to a text file and run it in your CAD program. See how it works.


I have also given you an explanation of the whole AutoLISP program. The program was not spectacular. But you saw some new things.




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


Drawing A Rectangle With AutoLISP 5

Function 5, 6, and 7


Here are the next three functions. They are the functions for drawing the paper, drawing the rectangle, and setting the variables.


Function 5


We are now going to draw the border of the drawing. It is done on the 025 layer and the 070 layer.


Firsst the appropriate layer is set and then lines are drawn using the LINE command. That is important. The scale factor is used.


The scale factor is given to the function. And the length of the lines that are drawn are multiplied with the scale factor.


(defun drpap (sc)
(command "layer" "s" "025" "")
(command "line" (setq pt (list 0 0))
(setq pt (polar pt
0
(* 420 sc)))
(setq pt (polar pt
(* pi 0.5)
(* 297 sc)
)
)
(setq pt (polar pt
pi
(* 420 sc)
)
)
"c"
)
(command "layer" "s" "070" "")
(command "line" (setq pt (list 0 0)
pt (polar pt 0 (* 10 sc))
pt (polar pt
(* 0.5 pi)
(* 10 sc)
)
)
(setq pt (polar pt
0
(* 400 sc)
)
)
(setq pt (polar pt
(* pi 0.5)
(* 277 sc)
)
)
(setq pt (polar pt
pi
(* 400 sc)
)
)
"c"
)
)


Function 6


Now the rectangle is drawn. The width and the height of the rectangle are given to the function. Also the scale factor.


First the midpoint of the drawing is found. That is where the scale factor comes in. Next the points of the rectangle are calculated.


The rectangle is drawn using the RECTANGLE command. Also see that the 050 layer is set before the rectangle is drawn.


(defun drfig (wd ht sc)
(setq cp (setq cp (polar (list 0 0)
0
(* 420 sc 0.5)
)
cp (polar cp
(* pi 0.5)
(* 297 sc 0.5)
)
)
)
(command "layer" "s" "050" "")
(setq p1 (polar cp pi (* wd 0.5))
p1 (polar p1 (* pi 1.5) (* ht 0.5))
)
(setq p2 (polar cp 0 (* wd 0.5))
p2 (polar p2 (* pi 0.5) (* ht 0.5))
)
(command "rectangle" p1 p2)
)


Function 7


Dimension are added to the rectangle. Before that can be done, the dimension variables need to be set. It is done here.


I'm not going to explain what the functions of each dimension variable are. If you want an explanation, do a search on Google.


(defun dmvar (sc)
(setvar "dimasz" 10)
(setvar "dimcen" 10)
(setvar "dimclrt" 2)
(setvar "dimdec" 0)
(setvar "dimdli" 1.25)
(setvar "dimexe" 1.25)
(setvar "dimexo" 1.25)
(setvar "dimgap" 1.25)
(setvar "dimtdec" 0)
(setvar "dimtih" 0)
(setvar "dimtoh" 0)
(setvar "dimtvp" 5)
(setvar "dimtxt" 10)
(setvar "dimgap" 2.5)
(setvar "dimscale" sc)
)


Next Post


In the next post I'm going to talk about the remaining three functions of the AutoLISP program. I'll give an explanation of them.




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


Wednesday, November 6, 2013

Drawing A Rectangle With AutoLISP 4

Function 1, 2, 3, And 4


I'm now going to talk about the first three functions of the AutoLISP program. Here is the explanation of the three functions.


Function 1


The AutoLISP program starts with a call to this function. The CMDECHO system variable is set to zero. I do not want command echos.


Next there is checked if there are entities in the drawing. If so, all these entities are deleted. We start with an empty screen.


(defun start ()
(setvar "cmdecho" 0)
(command "zoom" "all")
(setq p1 (getvar "vsmin")
p2 (getvar "vsmax")
)
(setq ss (ssget "c" p1 p2))
(if ss
(command "erase" "all" "")
)
)


Function 2


With the second function the dialog box is displayed. First a flag gets the value zero. The width and the height gets a value too.


After setting those values, there is the WHILE loop. There is stayed in the WHILE loop as long as the variable FL has the value zero.


The dialog box is loaded into the AutoLISP program and next the dialog box is displayed. There are the LOAD_DIALOG and the NEW_DIALOG functions.


The image is displayed. A slide is loaded into the AutoLISP program. The sizes of the image has been set. It is found in the DCL file.


The width and the height tiles get the value from before. The focus is set in the width tile. And values are entered.


The values that are entered plus the value of the flag and the scale are given back to the fucntion by the VALUE function.


Those values are stored in a list. The values in the list are found. Also the value of the flag variable.


(defun dlgbx (/ di fl hi ls nr oh th wd wi)
(setq fl 0
wd 300
ht 200
)
(while (= fl 0)
(setq di (load_dialog "c:/make/rectg.dcl"))
(new_dialog "rt" di)
(setq wi (dimx_tile "im")
hi (dimy_tile "im")
)
(start_image "im")
(fill_image 0 0 wi hi 0)
(slide_image -150 -150
(+ wi 150)
(+ hi 150)
"c:/make/rectg.sld"
)
(end_image)
(set_tile "wd" (itoa wd))
(set_tile "ht" (itoa ht))
(mode_tile "wd" 3)
(action_tile "accept" "(setq ls (value))
(done_dialog)"
)
(start_dialog)
(unload_dialog di)
(setq fl (nth 0 ls)
wd (nth 1 ls)
ht (nth 2 ls)
sc (nth 3 ls)
)
)
(list wd ht sc)
)


Function 3


Function 3 is the VALUE function. The second function makes a call to that function. The width and the height are found.


There is the CONDITION function. It is used to find the scale of the drawing. It checks the value of width and height.


But there is a maximum for the width and the height. If the width or the height is more than the maximum, a dialog box is displayed.


If the value of the width and the height is less than what is the maximum, then the FL variable gets the value of one.


The value of the flag, the width, the height, and the scale is pout in a lsit. And the list is given back to function 2.


(defun value (/ fl nr oh th wd)
(setq wd (atoi (get_tile "wd"))
ht (atoi (get_tile "ht"))
fl 0
)
(cond
((and (<= wd 350) (<= ht 250))
(setq sc 1)
)
((and (<= wd 700) (<= ht 500))
(setq sc 2)
)
((and (<= wd 1750) (<= ht 1250))
(setq sc 5)
)
((and (<= wd 3500) (<= ht 2500))
(setq sc 10)
)
)
(if (> wd 3500)
(alert "The maximum width is 3500")
)
(if (> ht 2500)
(alert "The maximum height is 2500")
)
(if (and (<= wd 3500) (<= ht 2500))
(setq fl 1)
)
(list fl wd ht sc)
)


Function 4


With this function the layers are set or they are created if they not exist. The TBLSEARCH function is used.


(defun chlay ()
(if (tblsearch "layer" "025")
(command "layer" "s" "025" "")
(command "layer" "m"
"025"
"c"
1
""
""
)
)
(if (tblsearch "layer" "050")
(command "layer" "s" "050" "")
(command "layer" "m"
"050"
"c"
3
""
""
)
)
(if (tblsearch "layer" "070")
(command "layer" "s" "070" "")
(command "layer" "m"
"070"
"c"
4
""
""
)
)
(if (tblsearch "layer" "dimensions")
(command "layer" "s" "dimensions" "")
(command "layer" "m"
"dimensions"
"c"
1
""
)
)
(if (tblsearch "layer" "text")
(command "layer" "s" "text" "")
(command "layer" "m"
"text"
"c"
2
""
""
)
)
)


Very good. I have talked about the first four functions of the AutoLISP prgoram. I have given an explanation about them.




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


Tuesday, November 5, 2013

Drawing A Rectangle With AutoLISP 3

The DCL File


The AutoLISP program works with a dialog box. So we need a DCL file. In the DCL file the dialog box is specified.


Here is the DCL file:


rt:dialog
{
label="Draw Rectangle";
: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 = 15;
initial_focus = true;
}
: edit_box
{
key = "ht";
label = "Height:";
edit_width = 15;
}
spacer_1;
}
spacer_1;
ok_only;
}


The DCL file starts with a specification of the image. The height and the width of the image is given. The key is also given.


Next two edit boxes are specified in the DCVL file. Those are the edit boxes for entering the width and the height.


Both edit boxes are displayed in a box. You could see that in the first post of this series. There is only an OK button in the dialog box.


This is enough for now. In my next posts I'm going to talk about the functions of the AutoLISP program. I will do it in three installments.




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


Monday, November 4, 2013

Drawing A Rectangle With AutoLISP 2


The AutoLISP Program


Here is the AutoLISP program. It is a very long program. The number of lines is 259. But the AutoLISP program needs to be that long.


(defun c:rectg ()
(start)
(setq ls (dlgbx)
wd (nth 0 ls)
ht (nth 1 ls)
sc (nth 2 ls)
)
(chlay)
(drpap sc)
(drfig wd ht sc)
(dmvar sc)
(drdim sc)
(drscl sc)
(endpr)
)


(defun start ()
(setvar "cmdecho" 0)
(command "zoom" "all")
(setq p1 (getvar "vsmin")
p2 (getvar "vsmax")
)
(setq ss (ssget "c" p1 p2))
(if ss
(command "erase" "all" "")
)
)


(defun dlgbx (/ di fl hi ls nr oh th wd wi)
(setq fl 0
wd 300
ht 200
)
(while (= fl 0)
(setq di (load_dialog "c:/make/rectg.dcl"))
(new_dialog "rt" di)
(setq wi (dimx_tile "im")
hi (dimy_tile "im")
)
(start_image "im")
(fill_image 0 0 wi hi 0)
(slide_image -150 -150
(+ wi 150)
(+ hi 150)
"c:/make/rectg.sld"
)
(end_image)
(set_tile "wd" (itoa wd))
(set_tile "ht" (itoa ht))
(mode_tile "wd" 3)
(action_tile "accept" "(setq ls (value))
(done_dialog)"
)
(start_dialog)
(unload_dialog di)
(setq fl (nth 0 ls)
wd (nth 1 ls)
ht (nth 2 ls)
sc (nth 3 ls)
)
)
(list wd ht sc)
)


(defun value (/ fl nr oh th wd)
(setq wd (atoi (get_tile "wd"))
ht (atoi (get_tile "ht"))
fl 0
)
(cond
((and (<= wd 350) (<= ht 250))
(setq sc 1)
)
((and (<= wd 700) (<= ht 500))
(setq sc 2)
)
((and (<= wd 1750) (<= ht 1250))
(setq sc 5)
)
((and (<= wd 3500) (<= ht 2500))
(setq sc 10)
)
)
(if (> wd 3500)
(alert "The maximum width is 3500")
)
(if (> ht 2500)
(alert "The maximum height is 2500")
)
(if (and (<= wd 3500) (<= ht 2500))
(setq fl 1)
)
(list fl wd ht sc)
)


(defun chlay ()
(if (tblsearch "layer" "025")
(command "layer" "s" "025" "")
(command "layer" "m"
"025"
"c"
1
""
""
)
)
(if (tblsearch "layer" "050")
(command "layer" "s" "050" "")
(command "layer" "m"
"050"
"c"
3
""
""
)
)
(if (tblsearch "layer" "070")
(command "layer" "s" "070" "")
(command "layer" "m"
"070"
"c"
4
""
""
)
)
(if (tblsearch "layer" "dimensions")
(command "layer" "s" "dimensions" "")
(command "layer" "m"
"dimensions"
"c"
1
""
)
)
(if (tblsearch "layer" "text")
(command "layer" "s" "text" "")
(command "layer" "m"
"text"
"c"
2
""
""
)
)
)


(defun drpap (sc)
(command "layer" "s" "025" "")
(command "line" (setq pt (list 0 0))
(setq pt (polar pt
0
(* 420 sc)))
(setq pt (polar pt
(* pi 0.5)
(* 297 sc)
)
)
(setq pt (polar pt
pi
(* 420 sc)
)
)
"c"
)
(command "layer" "s" "070" "")
(command "line" (setq pt (list 0 0)
pt (polar pt 0 (* 10 sc))
pt (polar pt
(* 0.5 pi)
(* 10 sc)
)
)
(setq pt (polar pt
0
(* 400 sc)
)
)
(setq pt (polar pt
(* pi 0.5)
(* 277 sc)
)
)
(setq pt (polar pt
pi
(* 400 sc)
)
)
"c"
)
)


(defun drfig (wd ht sc)
(setq cp (setq cp (polar (list 0 0)
0
(* 420 sc 0.5)
)
cp (polar cp
(* pi 0.5)
(* 297 sc 0.5)
)
)
)
(command "layer" "s" "050" "")
(setq p1 (polar cp pi (* wd 0.5))
p1 (polar p1 (* pi 1.5) (* ht 0.5))
)
(setq p2 (polar cp 0 (* wd 0.5))
p2 (polar p2 (* pi 0.5) (* ht 0.5))
)
(command "rectangle" p1 p2)
)


(defun dmvar (sc)
(setvar "dimasz" 10)
(setvar "dimcen" 10)
(setvar "dimclrt" 2)
(setvar "dimdec" 0)
(setvar "dimdli" 1.25)
(setvar "dimexe" 1.25)
(setvar "dimexo" 1.25)
(setvar "dimgap" 1.25)
(setvar "dimtdec" 0)
(setvar "dimtih" 0)
(setvar "dimtoh" 0)
(setvar "dimtvp" 5)
(setvar "dimtxt" 10)
(setvar "dimgap" 2.5)
(setvar "dimscale" sc)
)


(defun drdim (sc)
(command "layer" "s" "dimensions" "")
(command "dimlinear" p1
(polar p1 0 wd)
(polar p1
(* pi 1.5)
(* 20 sc)
)
)
(command "dimlinear" p2
(polar p2 (* pi 1.5) ht)
(polar p2 0 (* 20 sc))
)
)


(defun drscl (sc)
(command "layer" "s" "text" "")
(command "text" "r"
(setq pt
(polar (list 0 0)
0
(+ (* sc 10)
(* (- 400 10) sc
)
)
)
pt (polar pt
(* pi 0.5)
(* 20 sc)
)
)
(* 10 sc)
0
(strcat "Scale "
(rtos sc 2 0)
)
)
)


(defun endpr ()
(command "zoom" "all")
(setvar "cmdecho" 1)
(princ)
)


(c:rectg)


In my next post. I'm going to talk about the DCL file that comes with this AutoLISP program. You know. We need the DCL file.




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, November 3, 2013

Drawing A Rectangle With AutoLISP 1

Introduction


Here is an AutoLISP program for drawing a rectangle. You can enter the sizes of the rectangle in a dialog box.


Once the sizes have been entered the rectangle is drawn. The scale of the drawing is written in the drawing.


That is important. You can enter a width and a height for the rectangle. But the maximum width is 3500. The maximum height is 2500.


How The AutoLISP Program Works


As the AutoLISP program starts a dialog box is displayed. In it the width and the height of the rectangle can be entered.


See the dialog box. The user can enter the width of the rectangle and the height of the rectangle. But there are maximums.


The maximum width is 3500. If a value more than 3500 is entered, then a warning dialog box is displayed. Have a look at it.


The same happens for the height. The maximum height is 2500. If a higher value is entered, a warning dialog box is displayed.


After the warning dialog box have been displayed, the user clicks on the OK button. And he can enter other values.


The values he entered are displayed in the dialog box.







The user has entered a valid width and height of the rectangle. The rectangle is drawn with dimensions.


This is how it looks:




The scale of the drawing is written in the lower right corner of the drawing. The scale can go op to 1:10.


I guess that is what you want. You want to have the listing of the AutoLISP program. You will get it. In my next post.




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