Thursday, November 7, 2013

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


No comments:

Post a Comment