Showing posts with label Make AutoCAD Fast. Show all posts
Showing posts with label Make AutoCAD Fast. Show all posts

Monday, March 17, 2014

Drawing A Polyline with AutoLISP 5

The DELPL Function


Now I'm going to talk about the next function of the AutoLISP program. I'm going to talk about the DELPL function. Here it is:


(defun-delpl-(/-et-el-tp)
---(setq-et-(entlast)
---------el-(entget-et)
---------tp-(cdr-(assoc-0-el))
---)
---(if-(=-tp-"LWPOLYLINE")
------(command-"erase"-(entlast)-"")
---)
)


The function is used as the AutoLISP program starts. It deletes a polyline. A call to it is in the main AutoLISP program.


Working Of The Function


The function works like this. The last entity in the drawing is found. The ENTLAST function is used.


The type of the last entity is found. If the type is a polyline, the name is LWPOLYLINE, then it is deleted.


The polyline is deleted with this programming line:


(command-"erase"-(entlast)-"")


Important


I told you. As the AutoLISP program works, then the polyline that has been drawn by the program, is deleted.


Next Post


I keep this post short. In my next post I'm going to talk about the next function. I'm going to talk about the DRWPL function.


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.

Thursday, March 13, 2014

Drawing Polylines with AutoLISP 1

I haven't been talking about AutoLISP lately. I don't know. Are you thinking I feel I have talked enough about AutoLISP?


If you were thinking in a negative way. Stop doing that. Now I'm going to talk about an AutoLISP program that I created.


I have created the AutoLISP program for a couple of my students. They wanted to learn programming in AutoLISP.


The Program




The program starts. Four lines are drawn. See the opening screen that shows up. See how the four lines look.


After the program has started. The opening screen is displayed in the screen. And there is asked to select a line.


A line is selected. And a polyline is drawn over the line. This is how it looks if a horizontal line has been selected.




But the vertical line could also have been selected. If that is done, then the polyline is drawn over the selected area.


See how looks. The polyline is not drawn over the whole line. It is only drawn over the area where the line was selected.




That is important. After a line has been selected, the previously drawn polyline is erased. So it is no longer there.


One more thing. The user is asked to select a line. But you know how users are. Do they do it on purpose? They may select a polyline.


Well. If they select a polyline, the AutoLISP program will not crash. The polyline will be erased and a new one is drawn.


Next Post


In my next post I'm going to talk about the AutoLISP program. I'm going to give you the whole listing and tell you what needs to be done.


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.








Wednesday, March 12, 2014

What AutoLISP Reveals

You are working with AutoCAD. Or maybe you are working with an alternative of AutoCAD such as IntelliCAD.


In the program you are creating technical drawings. The guess is that you are creating a lot of technical drawings with the program.


That Is How It Is


It takes a lot of time before your technical drawing is is created. And once it is created, you cannot use it right away.


The technical drawing needs to be checked first. And checking the technical drawing. That takes a lot of time too.


Wasting Time And Money


That is what AutoLISP reveals. You are wasting a lot of time and money. You could work with an AutoLISP program.


The AutoLISP program could be used to create parts of your technical drawing. It could even be used to create a complete drawing.


And that is how it is. Creating a complete technical drawing with an AutoLISP program is very fast. It is done in seconds.


If a complete technical drawing is created with an AutoLISP program. You don't have to wait for hours before the technical drawing is created.


And you don't have to check the technical drawing. In the AutoLISP program is laid down what standards are to be used.


OK. I said that a technical drawing is created in seconds with an AutoLISP program. Let's be honesty. It may take longer.


Suppose the AutoLISP program works with dialog boxes. Filling in the dialog boxes takes time. So it may be one minute.


Even if the AutoLISP program is creating parts of your technical drawing, you are saving a lot of time. You can imagine.


No AutoLISP Program


If you want to create a complete technical drawing with AutoLISP or parts of it, then you need an AutoLISP program.


But an AutoLISP program is not the only solution. You could also have a Visual Basic program or a program written in C++.


A Visual Basic program? Sure. Your program could be a Visual Basic program if you are working with an older version of AutoCAD.


Because nowadays AutoCAD is no longer supporting program that are written in Visual Basic. Now only AutoLISP and C++ programs are supported.


Disadvantage Of A C++ Program


A C++ program has got a big disadvantage. It is the price. The price of a C++ program is much higher than that of an AutoLISP program.


Can more be done with a C++ program than an AutoLISP program? No. You can do the same with AutoLISP and C++ programs.


Make AutoCAD Fast


If you are interested in getting an AutoLISP program, you could come to me. I can write an AutoLISP program for you.




If interested, give me a call. If you are from Malaysia. This is my telephone number:


012-9312742


From outside Malaysia you must dial:


+60129312742


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.








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.








Sunday, March 9, 2014

The Border Application


You or your people are working with AutoCAD. All the time drawing are created. And each drawing has got a border and drawing head.


Creating the border and the drawing head takes a lot of time. What are the sizes of the border and the drawing head?


And what is going to be written in the drawing head? The name of the drawing, the scale, the draftsman, the date?


I have created an AutoLISP application, that will draw the border and the drawing head for you. Once the drawing has been created.


The AutoLISP application works with a dialog box. And the dialog box needs to be filled in. That takes time.


But it doesn't take as much time as drawing the border and the drawing head. With the AutoLISP application the job is done within one minute.


Don't you think you would be saving a lot of time of you are working with the AutoLISP application? You will save hours of work.


Here is how the AutoLISP application works. The one that I have written. At the start this drawing is created.


The drwazing represents the three views of an AutoCAD drawign. There is the front view, the side view, and the top view.






Next a dialog boil shows up. In the dialog box you can select what drawing size you want:


- A4
- A3
- A2
- A1


Here is the dialog box. The box for selecting the drawing size is expanded. After the selection you can click on the OK button.




You cannot select A0 for the size of the drawing. I understand that that size is no longer used for technical drawings.


After clicking on the OK button, the border is drawn and also the drawign head. This is how an A4 drawing looks.




Do you see? The size of the drawing can be found in the drawing head and also the scale of the drawing.


Are you interested in this AutoLISP application? Would you like to have it and save a lot of time when creating AutoCAD drawings?


I can write the AutoLISP application for you. If I do, I will charge you only RM 500. Tha tis less than $ 165.


But I have some questions. What paper size are you using? Is it always the same size? If so then there is no need to ask for a size.


I would also like to have the logo that you are working with. I guess you have it in a JPG file. Or I could create such a file for you.


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.




Saturday, March 8, 2014

An AutoCAD Operator

I was at Putra World Trade Center in Kuala Lumpur. There I met the director of an engineering firm. I told him about the border application.


He was interested in the border application. He wanted to have it. He saw that with it his AutoCAD operator would save a lot of time.


Two Days Later


We met again three days later. I wanted to show him the border application and I had some questions. But he could not take it.


He explained to me what was the problem was. He had talked the border application over with his AutoCAD operator. And he didn't want it.


I understood why the AutoCAD operator did not want the border application. He was afraid that when it was used, he would loose his job.


My Suggestion


I suggested my customer that he should talk to his AutoCAD operator. He should tell him that he is expecting that more AutoCAD work would come.


He should also tell his AutoCAD operator that he was thinking of engaging another AutoCAD operator. The border application made him change his mind.


Talking To His AutoCAD Operator


My customer talked to his AutoCAD operator. He told him about his plan to engage an extra AutoCAD operator and more AutoCAD work.


I asked my customer if he was thinking of getting rid of his AutoCAD operator. I said to him that I could not imagine he would.


My customer had told him that he would keep his job. Why not? My customer needed him to do all the AutoCAD work.


The Objections Were Gone


The AutoCAD operator got the feeling that he was not going to loose his job. His objections against the border application? They were gone.


The AutoCAD operator promised that he would use the border application if he knew how it worked. That was very good.


Saving A Lot Of Time


A few days later I delivered the border application to the director. His AutoCAD operator is saving a lot of time now.


I sold the border application to the director for RM 600.-. That is far less than what he would have to pay for an extra AutoCAD operator.


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.








Friday, January 10, 2014

Another AutoLISP And DCL Program 2


Introduction


Now I'm going to talk about the AutoLISP file and the DCL file. I will start with talking about the DCL file.


The DCL File


Here is the DCL file. It is not really complicated. See how the ALIGNMENT attributes and the SPACER attributes are used.


selpt : dialog
{
label = "Select Point";
: boxed_column
{
label = "Sample Point";
: spacer
{
height=1;
}
: button
{
label = "Pick Point <";
key = "hide";
width = 12;
fixed_width = true;
mnemonic = "P";
alignment = centered;
}
: spacer
{
height=1;
}
: edit_box
{
key = "px";
label = "&X:";
width = 8;
fixed_width = true;
alignment = centered;
}
: edit_box
{
key = "py";
label = "&Y:";
width = 8;
fixed_width = true;
alignment = centered;
}
: edit_box
{
key = "pz";
label = "&Z:";
width = 8;
fixed_width = true;
alignment = centered;
}
: spacer
{
height=1;
}
}
: spacer
{
height=1;
}
ok_cancel;
}


In the DCL file a button is specified and there are three edit boxes in the dialog box file. You see what text is displayed.


You can also see what the keys of the button and the text boxes are. The AutoLISP program makes a reference to them.


The AutoLISP Program


Here is the AutoLISP program. I did not follow what was given by AFRALISP. Their program has no functions. My version has.


(defun c:selp ()
(start)
(setq px "0.000"
py "0.000"
pz "0.000"
fl 4
)
(setq di (load_dialog "c:/make/selpt.dcl"))
(while (> fl 2)
(if (not (new_dialog "selpt" di))
(exit)
)
(sttle px py pz)
(action_tile "cancel" "(done_dialog 1)")
(action_tile "accept"
"(setq px (get_tile \"p1\"))
(setq py (get_tile \"p2\"))
(setq pz (get_tile \"p3\"))
(done_dialog 2)"
)
(action_tile "hide" "(done_dialog 4)")
(setq fl (start_dialog))
(if (= fl 4)
(progn
(setq ls (selpt)
px (nth 0 ls)
py (nth 1 ls)
pz (nth 2 ls)
)
)
)
)
(unload_dialog di)
(endpr)
)


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


(defun sttle (px py pz)
(set_tile "px" px)
(set_tile "py" py)
(set_tile "pz" pz)
)


(defun selpt ()
(setq selpoint (getpoint
"\nInsertion Point: "
)
)
(setq px (rtos (car selpoint) 2 4))
(setq py (rtos (cadr selpoint) 2 4))
(setq pz (rtos (caddr selpoint) 2 4))
(list px py pz)
)


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


(c:selp)


I have added the following functions to the program:


1. START
2. STTLE
3. SELPT
4. ENDPR


You already know about the first and the last function. So I don't have to give an explanation about them.


As the AutoLISP program starts, a call is made to the START function. You know what is done by the START function.


Next start values are given to the following three variables:


PX
PY
PZ


The variables get the value “0.000”.


The FL variable gets the value. That variable is used for the WHILE function, that comes next. If continues as long as the value is more than two.


Before the WHILE function is started the dialog box is loaded into the AutoLISP program. It isn't displayed yet.


In the WHILE function the dialog box is displayed. And the PX, PT, and PZ tile get the value that has been given to the variables.


That is done with the second function. It is done with the STTLE function. That function is used again and again.


Next ACTION_TILE functions are used. Those functions are used as there is clicked on one of the buttons.


There can be clicked on the CANCEL button, on the OK button, or on the PICK Point button. These are the keys of the buttons:


Button
Key




CANCEL
CANCEL
OK
ACCEPT
PICK POINT
HIDE


DONE_DIALOG is given a value. The value depends on the button that has been clicked. These are the values:


Button
Value




CANCEL
0
OK
1
PICK POINT
4


If there has been clicked on the PICK Point button, then a point is picked in the screen. And a new value for PX, PY, and PZ is found.


We come again to the STTLE function. And the new values are given to the PX, PY, and PZ tiles. And they are displayed in the dialog box.


After clicking on the PICK POINT button, the FL value is given the value 4. So we stay in the WHILE loop.


If there is clicked on the CANCEL button or the OK button, then the FL variable gets the value zero or one. There is jumped out of the WHILE loop.


When there is jumped out of the WHILE loop, then the AutoLISP program ends. No so if there is clicked on the PICK POINT button.


OK. This is the explanation of the AutoLISP program. Now you know how the AutoLISP program works. I hope it is clear.


But that is the most important part. Now you have seen how you can perform an AutoLISP action if a dialog box is displayed.


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


Friday, December 27, 2013

AutoLISP And DCL 2

Introduction


In my last post I said that I will give an explanation about the DCL file and the AutoLISP file. Here is the explanation.


The DCL File


You steady have seen the DCL file. In the DCL file the tiles of the dialog box are specified. The dialog box has got a button and a pop up list.


There is not much that can be said about the DCL file. I presume the DCL file is pretty clear to you. One thing.


For the button I have specified a height. That is done to make it easier to click on the button for selecting a text.


The AutoLISP File


The AutoLISP file works with the following six functions:


- START
- VALUE
- SELTX
- FNDDT
- DRBOX
- ENDPR


I have already talked about the START function and the ENDPR function. So I don't need to give an explanation about them again.


A call to the VALUE function is made when there is clicked on the OK button. We want to know what value is selected.


There must be clicked on the SELECT TEXT button. When that is done a call to the SELTX fucntion is made. To find what text has been selected.


But before I go any further. I must tell you about the WHILE loop in the AutoLISP program and the FL variable.


At the start if the program the FL variable gets the value two. And the WHILE loop continues as long as the value of FL is more than one.


Before the start of the WHILE loop the DCL file is loaded into the AutoLISP program. The dialog box is displayed in the WHILE loop.


At the beginning of the AutoLISP program the LS variable is specified. The variable is a list. It has the values "2" "3" "4" and "5".

The pop up list has got values. The values are loaded into the pop up list. See how it is done. Using the list from before.

Three action tiles have been specified in the WHILE loop. Here they are:

Action tile
Button
Value



CANCEL
Cancel button
0
ACCEPT
OK button
1
SELECT
Select text button
2

When the button is clicked, the DONE_DIALOG function is performed. And with it a value is stored.

The START_DIALOG function is performed and with it the value that was stored with the DONE_DIALOG function is given back.

The value is given to the FL variable. If the value is zero or one, then the WHILE loop terminates.

If the value if the FL variable is two, then the dialog box disappears and a text can be selected. The text is stored in the TX variable.

That is important. The text can be selected after the SELECT TEXT button has been clicked. The FL variable gets the value two.

The selection of the text has to take place right after the value of the FL variable has been found using the START_DIALOG function.

In the first post I told you about the mistake a user can make. He can forget to select a text and click on the OK button.

If that happens the value of the FL variable is one and the value of the TX variable is nil. A warning is displayed.

But we stay in the dialog box. Because if the OK button of the warning is clicked, then the dialog box is displayed again.

The dialog box is also displayed again after a text has been selected. Now the user van select what spacing he or she wants.

The value of the FL variable is zero or one. There has been clicked on the OK button or the Cancel button.

The WHILE loop is terminated and the DCL file is unloaded from the AutoLISP program using the UNLOAD_DIALOG function.

Now we need to find the data. We need to find what spacing is wanted and information of the text that has been selected.

The spacing is found in the list. The value of the selection gives the item of the list. It is tuned into an integer with the ATOI function.

The information about the text is found with the FNDDT function. This is the information that is found:

- IP
- LG
- HT
  • RA
See how it is done. The entity list of the text is found and then the CDR function and the ASSOC function is used to find the data.

When all the information is found, the box around the text can be drawn. Thar is done with the DRBOX function.

Do you see that? The insertion point of the text is taken and changed depending on the value of the spacing.

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?




Thursday, December 19, 2013

11 AutoLISP Functions For Quickly Drawing Views 2

The AutoLISP Program


Here is the AutoLISP program. You will see the eleven functions here.


(defun c:crtvw (/ ls p1 p2 ls lt ht tp)
(start)
(clscr)
(drwor)
(zmdrw)
(setq ls (fdpts)
p1 (nth 0 ls)
p2 (nth 1 ls)
)
(setq ls (fltht p1 p2)
lt (nth 0 ls)
ht (nth 1 ls)
)
(setq tp (seltp))
(if (= tp "Flat")
(drwfl p2 lt ht)
(drwsh p2 lt ht)
)
(zmdrw)
(endpr)
)


(defun start (/ ss)
(setvar "cmdecho" 0)
(command "limits" (list 0 0)
(list 280 120)
)
(command "snap" 10)
(command "zoom" "extents")
(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 clscr (/ p1 p2 ss)
(command "zoom" "extents")
(setq p1 (getvar "vsmin")
p2 (getvar "vsmax")
)
(setq ss (ssget "c" p1 p2))
(if ss
(command "erase" "all" "")
)
)


(defun drwor (/ p1 p2)
(setq p1 (getpoint "\nFirst point rectangle: ")
p2 (getcorner p1 "\nOpposite point
rectangle:
"
)
)
(command "rectang" p1 p2)
(command "explode" (entlast))
)


(defun zmdrw ()
(command "zoom" "extents")
(command "zoom" "0.8x")
)


(defun fdpts (/ d1 d2 d3 d4 e1 e2 el p1 p2 p3 p4 ss)
(setq p1 (getvar "vsmin")
p2 (getvar "vsmax")
)
(setq ss (ssget "c" p1 p2)
e1 (ssname ss 0)
el (entget e1)
p1 (cdr (assoc 10 el))
p2 (cdr (assoc 11 el))
d1 (distance (list 0 0) p1)
d2 (distance (list 0 0) p2)
)
(if (< d1 d2)
(setq p1 p1)
(setq p1 p2)
)
(setq e2 (ssname ss 1)
el (entget e2)
p3 (cdr (assoc 10 el))
p4 (cdr (assoc 11 el))
d3 (distance (list 0 0) p3)
d4 (distance (list 0 0) p4)
)
(if (> d3 d4)
(setq p2 p3)
(setq p2 p4)


(list p1 p2)
)


(defun fltht (p1 p2 / x1 x2 lt y1 y2 ht)
(setq x1 (car p1)
x2 (car p2)
lt (abs (- x1 x2))
)
(setq y1 (cadr p1)
y2 (cadr p2)
ht (abs (- y1 y2))
)
(list lt ht)
)


(defun seltp (/ tp)
(initget 1 "Flat Shaft")
(setq tp (getkword "\nType: Flat/Shaft: "))
)


(defun drwfl (pt lt ht / dt pt wd)
(setq wd (getint "\nWidth: ")
dt (getint "\nDepth: ")
)
(command "line" (setq pt (polar pt 0 10))
(setq pt (polar pt 0 wd))
(setq pt (polar pt
(* pi 1.5)
ht
)
)
(setq pt (polar pt pi wd))
"c"
)
(command "line" (setq pt (polar pt
(* pi 0.5)
(+ 10 ht)
)
pt (polar pt pi 10)
)
(setq pt (polar pt
(* pi 0.5)
dt
)
)
(setq pt (polar pt pi lt))
(setq pt (polar pt
(* pi 1.5)
dt
)
)
"c"
)
)


(defun drwsh (pt lt ht / pt)
(setq pt (polar pt 0 (+ 10 (* ht 0.5)))
pt (polar pt (* pi 1.5) (* ht 0.5))
)
(command "circle" pt (* ht 0.5))
(command "line" (setq pt (polar pt
pi
(+ 10
(* ht 0.5)
)
)
pt (polar pt
(* pi 0.5)
(+ 10
(* ht 0.5)
)
)
)
(setq pt (polar pt
(* pi 0.5)
ht
)
)
(setq pt (polar pt pi lt))
(setq pt (polar pt
(* pi 1.5)
ht
)
)
"c"
)
)


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


(c:crtvw)


Next Post


Here you have the AutoLISP program. Copy it to a text file and save it under the name CRTVW.LSP. Load it into AutoCAD and work with it.


In the next post I'm going to talk about all the functions. I'm going to explain how they work and why they are there.


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