Monday, March 10, 2014

Discover How AutoLISP Deals With A Rectangle And Donuts 1


Here is an AutoLISP program. The program is used for drawing a rectangle and next donuts are drawn in the corners of the rectangle.


The Pictures


This is how it looks. The proforma starts. There is asked to pick the two points of the rectangle. Next the rectangle is drawn.


This is how it looks after the rectangle has been drawn.




The program finds the rectangle. And then it finds the corner points of the rectangle. And the donuts are drawn in the corner points.


Here is how the rectangle looks with the donuts in the corner points.




That was easy. The only thing the user had to do was picking two points. The AutoLISP program drew the donuts right away.


The AutoLISP Program


I know. You want to see the AutoLISP program. Very good. Here is the AutoLISP program. And I will tell you about all the functions.


(defun c:drdns (/ p1 p2 ls)
(start)
(setq p1 (getpoint "\nBasepoint: ")
p2 (getcorner p1 "\nUpper point: ")
)
(command "rectang" p1 p2)
(setq ls (fndls))
(drdns ls)
(endpr)
)


(defun start (/ ss)
(setvar "cmdecho" 0)
(command "limits" (list 0 0)
(list 280 120)
)
(command "snap" 10)
(command "grid" 10)
(command "zoom" "all")
(command "zoom" "0.8x")
(setq ss (ssget "c" (list 0 0)
(list 280 120)
)
)
(if ss
(command "erase" "all" "")
)
(command "-style" ""
"Courier New"
0
1
0
"No"
"No"
)
(command "zoom" "all")
(command "zoom" "0.8x")
)


(defun fndls (/ et el ls ct pl)
(setq et (entlast)
el (entget et)
ls nil
ct 0
)
(while (setq pl (nth ct el))
(if (= (car pl) 10)
(progn
(setq pt (cdr pl))
(if ls
(setq ls (append (list pt) ls))
(setq ls (list pt))
)
)
)
(setq ct (1+ ct))
)
ls
)


(defun drdns (ls / ct)
(setq ct 0)
(while (setq pt (nth ct ls))
(command "donut" 0 2.5 pt "")
(setq ct (1+ ct))
)
)


(defun endpr ()
(setvar "cmdecho" 1)
(princ)
)


(c:drdns)


The Next Post


In the next post I will tell you about all the functions that the AutoLISP program is having and why these functions are there.


There is also talked about the function. There is said how they work. But that comes in a post after the next post.


Something Completely Different


Here is something completely different from what you normally read in this blog. It is an imagination.


Imagine this. One day you wake up and you are a millionaire! Look at how different your life will be:


- You no longer have to worry about your debts, bills, and slaving for money.


- You can spend your time doing things you love, spend your time with your beloved family and friends.


- You no longer have to worry about money or have to be poor again. Never again living the life you used to have.


Do you want to be a millionaire? Make your dream lifestyle came true. Here's your chance to be a millionaire. Check this out.


Wake Up Millionaire:
http://l1nk.com/rfbzla



To Your Success


Free AutoLISP Course


Sorry. This offer is only for my readers from Malaysia. I want to give an AutoLISP course to them. Free of charge.


I have more than 900 readers. The majority of them is from the USA. More than 500. But I also have readers from Malaysia. About 120.


I don't know what my readers from Malaysia are doing. Are they with an engineering firm or architecture? Or just interested in AutoLISP?


I offer them a free AutoLISP course. It works like this. You let me know if interested and I'll come to your place.


I will give the AutoLISP course at your office. Your people can attend the AutoLISP course. The course consist of 15 lessons.


The first ten lessons are about AutoLISP. All the functions of AutoLISP are explained and there is talked about the system variables.


During the last five lessons we are going to write an AutoLISP program. The people attending the course come with a wish.


That is why this offer is only for my readers from Malaysia. I live in Malaysia. And I do not see how I could travel abroad.


The AutoLISP course is completely free. I will not charge you for the course. But I will ask you to refund my travel expenses.


The people attending the course will get an e-book about AutoLISP. The e-book is a PDF file. What is said in the course, can be found in the book.








No comments:

Post a Comment