Sunday, January 19, 2014

Drawing A Z Profile In AutoLISP

There was a request on an AutoLISP forum. Pity. I do not know exactly what AutoLISP forum. I did not write it drown.


Z Profile


A man wanted an AutoLISP profile that could draw a Z profile. That is how he called it. He called it a Z profile. Here it is.




The Z profile has got six sizes. I has got three length sizes: L1, L2, and L3. And three thickness sizes: T1, T2, and T3.


I wrote an AutoLISP program for him that could draws the Z profile. You must enter the sizes first.


I could have created an AutoLISP program that works with a dialog box. I did not do that. I kept the program simple.


The AutoLISP Program


Here is the AutoLISP program.


(defun c:drzpr ()
(start)
(setq ls (fdszs)
l1 (nth 0 ls)
l2 (nth 0 ls)
l3 (nth 0 ls)
s1 (nth 0 ls)
s2 (nth 0 ls)
s3 (nth 0 ls)
)
(drzpr l1 l2 l3 t1 t2 t3)
(endpr)
)


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


(defun fdszs (/ l1 l2 l3 t1 t2 t3)
(setq l1 (getint "\nL1: ")
l2 (getint "\nL2: ")
l3 (getint "\nL3: ")
t1 (getint "\nT1: ")
t2 (getint "\nT2: ")
t3 (getint "\nT3: ")
)
(list l1 l2 l3 t1 t2 t3)
)


(defun drzpr (l1 l2 l3 t1 t2 t3 / pt)
(command "line" (setq pt (polar (list 0 0)
(* pi 0.5)
l2
)
)
(setq pt (polar pt
0
l1
)
)
(setq pt (polar pt
(* pi 1.5)
(- l2 t1)
)
)
(setq pt (polar pt
0
(- l3 t2)
)
)
(setq pt (polar pt
(* pi 1.5)
t1
)
)
(setq pt (polar pt
pi
l3
)
)
(setq pt (polar pt
(* pi 0.5)
(- l2 t3)
)
)
(setq pt (polar pt
pi
(- l1 l2)
)
)
"c"
)
)


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


(c:drzpr)


The Functions


There is not much to say about the AutoLISP program. You see the START function and the ENDPR function. You know how they work.


For entering the sizes the GETINT function is used. My guess is that users only want to enter integer values.


In the function for drawing the Z profile the LINE command is used. Points are found and at the end of the LINE command there is a CLOSE.




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