Tuesday, November 26, 2013

AutoLISP For Lines and Circles 2

Introduction


I have talked about the AutoLISP program for lines and circles. I showed you how the program looks, what is created by the AutoLISP program.


Now I want to talk about all the functions of the AutoLISP program. You already know. Each function performs a task.


The START Function


Here is the function.


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


We have AutoCAD commands that are used in the AutoLISP program. We don't want command echos. So CMDECHO is s et to zero.


Next we want to delete everything that is in the screen. But is there something in the screen? This is how we check it.


The ZOOM ALL command is used. The corner points of the screen are found with VSMIN and VSMAX. Those points are used with the SSGET function.


If there is anything in the screen, the SSGET function gives back a value. And the ERASE ALL command is performed.


The GETIP Function


Here is the function.


(defun getip ()
(setq ip (getpoint "\nInsertion point: "))
)


This is not too complicated. The GETPOINT fucntion is used to pick a point. It is the last function, so it is given back by the GETIP function.


The DRWLN Function


Here is the function.


(defun drwln (ip)
( command "line" ip
(setq ip (polar ip
0
200
)
)
(setq ip (polar ip
(* pi 0.5)
200
)
)
(setq ip (polar ip
pi
100
)
)
(setq ip (polar ip
(* pi 1.5)
100
)
)
(setq ip (polar ip
pi
100
)
)
"c"
)
)


The insertion point is given to the function. And the six lines are drawn. The LINE command is used for doing that.


The DRWCR Function


Here is the function.


(defun drwcr (ip)
(command "circle" (setq ip (polar ip
(* pi 0.5)
50
)
ip (polar ip
0
50
)
)
25
)
(command "circle" (setq ip (polar ip
0
100
)
)
25
)
(command "circle" (setq ip (polar ip
(* pi 0.5)
100
)
)
25
)
)


Again. The insertion point is given to the DRWCR function. And the three circles are drawn. That is how simple it is.


The ENDPR Function


Here is the function.


(defun endpr ()
(command "zoom" "extents")
(command "zoom" "0.8x")
(setvar "cmdecho" 1)
(princ)
)


We are done with the AutoLISP program. We have picked a point, we have drawn the six lines, and we haqve drawn three circles.


Now we want to end the AutoLISP program. First we zoom to the EXTENTS of the drawing using the ZOOM command.


We want to make the drawing a little bit smaller. The ZOOM command is used again. The time the factor 0.8 is used.


We go again to the CMDECHO system variable. This time CMDECHO gets the value one. We are back in AutoCAD and we want command echos.


The Whole Program


Now you have got the whole program. You have seen what is does, you have got the whole listing, and you have got an explanation of all functions.




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