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?




Saturday, December 21, 2013

AutoLISP And DCL 1

Introduction


You know about DCL. Your AutoLISP program can work with dialog boxes. And you need a DCL file for doing that.


In the DCL file the dialog box is specified. What is specified, is displayed as the AutoLISP file starts.


But we have a problem. As long as the dialog box is displayed, we don't have access to AutoLISP. Or AutoCAD.


Well. Here is an AutoLISP program that works with a dialog box and that goes around this problem. You have access to AutoLISP.


How The Program Works


As the program starts a dialog box is displayed. Here is the dialog box that is displayed.




We can select a text by clicking on the button with the label “Select text”. If we do that the dialog box disappears.


In the command area of AutoCAD the following text is displayed:


Select text:


Now you can select a text.


After selecting a text the dialog box is displayed again. Now the user can select the spacing that he or she wants.


The spacing is the distance between the text and the box that will be drawn around the text. It can be from two till five.


But. You know how AutoCAD users can be. The dialog box invites us to select a text. But we have AutoCAD users that don't select a text.


They click on the OK button without selecting a text. So we need to warn them. That is done with this dialog box.




The user clicks on the OK button in the warning dialog box and the original dialog box is displayed again.


Now the riser knows that he has to click on the Select text button to select a text in the drawing.


The user can select any text. It doesn't matter how long the text is or what rotation angle it has. Here is an example.




The text is TEXT and it has been drawn under an angle of 30 degrees. Next a box is drawn around it. Here is how it looks.




As you can see. The box around the text has got the same angle as the text. And there is a spacing between the text and the box.


The AutoLISP Program And The DCL File


Normally I given the listing of the AutoLISP program in the second post. But this time I want to give it to you now.


Here is the AutoLISP program.


(defun c:txbox (/ di fl ht ip lg ls ra sp sl tx
vl
)
(start)
(setq ls (list "2" "3" "4" "5")
fl 2
)
(setq di (load_dialog "c:/make/txbox.dcl"))
(while (> fl 1)
(if (not (new_dialog "txbox" di))
(exit)
)
(start_list "space")
(mapcar 'add_list ls)
(end_list)
(action_tile "cancel" "(done_dialog 0)")
(action_tile "accept" "(setq vl (value))
(done_dialog 1)"
)
(action_tile "select" "(done_dialog 2)")
(setq fl (start_dialog))
(if (= fl 2)
(setq sl (entsel "\nSelect text: ")
tx (car sl)
)
)
(if (and (= fl 1) (null tx))
(progn
(alert "No text selected")
(setq fl 3)
)
)
)
(unload_dialog di)
(if (= fl 1)
(progn
(setq sp (atoi (nth (atoi vl) ls))
ls (fnddt tx)
ip (nth 0 ls)
lg (nth 1 ls)
ht (nth 2 ls)
ra (nth 3 ls)
)
(drbox ip sp lg ht ra)
)
)
(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 value (/ vl)
(setq vl (get_tile "space"))
vl
)


(defun seltx (/ tx)
(setq tx (car (entsel "\nSelect text: ")))
tx
)


(defun fnddt (tx / el ht ip lg ls ra v1 v2)
(setq el (entget tx)
ls (textbox el)
v1 (caar ls)
v2 (caadr ls)
lg (- v2 v1)
ip (cdr (assoc 10 el))
ht (cdr (assoc 40 el))
ra (cdr (assoc 50 el))
)
(list ip lg ht ra)
)


(defun drbox (ip sp lg ht ra)
(setq ip (polar ip (+ ra pi) sp)
ip (polar ip (- ra (* pi 0.5)) sp)
)
(command "line" ip
(setq ip (polar ip
ra
(+ lg (* sp 2))
)
)
(setq ip (polar ip
(+ ra
(* pi 0.5)
)
(+ ht
(* sp 2)
)
)
)
(polar ip
(+ ra pi)
(+ lg (* sp 2))
)
"c"
)
)


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


(c:txbox)


And here is the DCL file.


txbox : dialog
{
label = "Box Around Text";
: spacer
{
height=1;
}
: button
{
label = "Select text";
key = "select";
width = 12;
fixed_width = true;
alignment = centered;
height = 3;
}
: spacer
{
height=1;
}
: boxed_column
{
:popup_list
{
key = "space";
label = "Space";
edit_width = 2;
}
}
: spacer
{
height=1;
}
ok_cancel;
}


Next Post


In the next psot I will give an explanation of the AutoLISP file. You will also get an explanation of the DCL file.


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






































11 AutoLISP Functions For Quickly Drawing Views 4

Here are the remaining functions of the AutoLISP program.


SELTP


One more thing before the AutoLISP program can continue. What is to be drawn: a flat rectangle or a shaft?


It is found out with this function.


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


The initget function is used. The user is forced to make a selection. It can only select FLAT or SHAFT by entering F or S.


DRWFL


This function is used if the user has chosen to work with a flat rectangle. The three views are drawn. Here is the function.


(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"
)
)


First there is asked what the width and the depth of the side view and the top view are. You have seen where these sizes can be found.


When these two values are entered the side view and the top view are drawn. For doing that the LINE command is used.


DRWSH


The user has chosen that the rectangle stands for a shaft. Now the three views of the shaft need to be drawn. Here is the function.


(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"
)
)


There is no need to ask for sizes. The height of the rectangle is the diameter of the shaft. The diameter is for the side view and the top view.


One Last Remark


At the end of the listing you find this line:


(c:crtvw)


That is done so that the AutoLISP starts right away after it has been loaded into AutoCAD. Or a similar CAD program.


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


Friday, December 20, 2013

AutoLISP Functions For Quickly Drawing Views 3

As promised in the last post. This timeis talked about the functions of the AutoLISP program. Explained is how they work.


Functions


The AutoLISP program has got the following functions:


- CRTVW
- START
- CLSCR
- DRWOR
- ZMDRW
- FDPTS
- FLTHT
- SELTP
- DRWFL
- DRWSH
- ENDPR


CRTVW


This is the main function of the AutoLISP program. Through this function calls are made to the separate functions of the program.


Here is the function:


(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)
)


You can see what calls to functions are made.


START And ENDPR


There has been talked about those two functions. So there is no need to repeat what has been said. Here are both functions:


(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 endpr ()
(setvar "cmdecho" 1)
(princ)
)

CLSCR


When the program starts, there is made sure that the screen is empty. Everything that is in the screen is erased.


It is done with the CLRSR function. Here it is:


(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" "")
)
)


The ZOOM command is used and of it the EXTENTS option is used. That way everything that is in the screen is displayed.


The lower right point of the screen and the upper left point of the screen is found. Those points are used with the SSGET function.


If a selection set is found with the SSGET function, then the selection set is erased totally.


DRWOR


The first rectangle is drawn by the user. It is done with this function. Here is the function:


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


The user enters two points. First the user enters the lower right point of the rectangle and then the upper right point of the rectangle.


Using the RECTANGLE command the rectangle is drawn. Next the rectangle is exploded with the EXPLODE command.


The rectangle is exploded, because we need separate lines for what comes next.


ZMDRW


We want the rectangle displayed in the screen. That is where the ZMDRW function comes in. Here is the function.


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


The ZOOM command is used and the EXTENTS option of that command. Next the display of the screen is scaled down with factor 0.8.


FDPTS


The lower left point of the rectangle and the upper right point of the rectangle are needed. Later you will see why.


Here is the FDPTS function for finding the two points:


(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)
)


The drawing has been zoomed out and it has been scaled down with the ZMDRW function. The two points of the screen are found.


The points are used with the SSGET command to get the selection set. The selection set is the rectangle. Do you now see why it was exploded?


There are four entities in the selection set. The fist entity is the horizontal line and the second entity is the vertical line.


The points of both lines are taken to find the lower left corner of the rectangle and the upper right corner of the rectangle.


The start point and end point of each line is taken. And then the distance to the zero point is measured.


The smallest distance gives the lower left point of the rectangle. The biggest distance gives the upper right corner of the rectangle.


The two points that have been found are put in a list and given back to the main function.


FLTHT


The length and the height of the rectangle are needed for the rest of the program. It is found with this function.


(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)
)


The two points that were found with the previous function are given to the function. The X values are found with the CAR function.


The CADR function is used to find the Y values of the points. When the X values and Y values are found the length and the height can be found.


The length and the height are put in a list and given back to the main function.


Next Post


In this post not all functions have been specified. Some functions are remaining. You will find them in the next post.


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


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






Wednesday, December 18, 2013

11 AutoLISP Functions For Quickly Drawing Views 1

Imagine this. You have created the front view of your drawing. And now you want to get the side view and the top view.


Creating them. That is going to take a lot of time. Not if you are working with AutoLISP. Here is a program that does it very fast.


Limited


OK. I must admit. It is a limited program. The front view is a rectangle. And once we have it the side view and the top view is created.


But the principle is there. You can create quickly the side view and the top view if you have the front view of a drawing.


Depending on the drawing that you have got. Some more programming could be needed. But that is clear. It could be done with AutoLISP.


How The Program Works


I have created a program, that quickly creates a side view and a top view. This is how the program works.


The program starts. It starts with a clean sheet. If something has been drawn in the screen, then it is erased.


A rectangle is drawn. The user can decide what rectangle to draw. There is asked to pick the base point and the opposite point.


This is how the rectangle may look:




Next there is asked what is to be drawn. Do we have a flat rectangle or is the rectangle a shaft. There is asked what to draw.


This is the question that shows up:


Type: Flat/Shaft:


The user can enter “F” for flat or “S” for shaft. What is selected is drawn.


If the user has selected FLAT, then two more questions show up. There are asked what the width and the depth of the drawing is.


These are the questions:


Width:
Depth:


The rectangle also have got a length and a height. Here is a picture that explains all the sizes of the rectangle.




After the width and the depth have been entered, the side view and the top view of the rectangle is drawn. See how it is.




This is how the drawing looks if there has been chosen for a flat rectangle. But it could also be a shaft. This is how it looks if shaft.




Next


I'm talking about eleven functions and you want to have the program and learn about the eleven functions. You will get in 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.
-------------------------------------------------