Jump to content

how to create a new lisp(Easy method -pls help me )


K P Senthil Kumar

Recommended Posts

hi gud evening to all

 

Actually i want to learn Auto Lisp .so pls give me general information guide lines 2 me :roll::roll::roll::roll:

 

regards,

kpsk

Link to comment
Share on other sites

Welcome to the CADTutor forum K P.

 

Your question has been asked and answered a number of times. I suggest that you see Similar Threads listed below and/or use the Search function above and put the word "autolisp" in the search box.

 

Also, visit the AutoLISP Archive and check out some of the routines there.

 

I suggest you click on the Links button above and go through the list. Two sites I recommend are AfraLisp and Jeffery P Sanders if you want to learn more about the subject.

Link to comment
Share on other sites

This one is nice to start with:

(defun c:test2 (/) ; defun is where you put your function name the c: means your can run it from command window.
(cond ; cond is just a way to say if condition x is right do this as you see below
( (= 3 3) (princ "True") )                       ; princ puts some text in your cmd screen like this will put true in your command windows because 3 is equal to 3 Try it out!
( (= 4 2) (princ "True") )                       ;skips because 4 does not equal 2
( (= 4 1) (princ "True") )                       ;skips because 4 does not equal 1
( T (princ "Nothing") )                             ; prints "Nothing" if nothing is true.
)
 )

You can also try if with this:

(if (tblsearch "BLOCK" "template") (searches for a block called template if it is there it goes to next line)
  (progn (must be used if you want to do more then one line after the if)

Since I just started myself I know how hard it is to learn a little bit, so I hope this gets you on your way like it did with me.

Link to comment
Share on other sites

Here a simple box with a couple of twists pick two points then the side for the box with an offset chucked in.

 

As I have said before to many people who want to learn lisp vba etc get yourself a project to achieve 1st its not much good just reading the tutorials, pick something simple like drawing a box and get more and more complex.

 

The simplest task like drawing a pit we do every day yet we never bothered to do it after years of cad! Did it the other day and it took about 15 minutes.

 

; draw pits with 100mm walls
(setq oldsnap (getvar "osmode"))
(setq oldlayer (getvar "clayer")) 
(command "_layer" "n" "Design-Drainage-Pits" "c" 4 "Design-Drainage-Pits" "")
(setvar "clayer" "Design-Drainage-Pits")
(setq length (getreal "\nPlease enter length m eg 0.9: "))
(setq width (getreal "\nPlease enter width : "))
(setq pt1 (getpoint "\npick 1st point to place pit : "))
(setq pt2 (getpoint "\nPick 2nd point for orientation"))
(setvar "osmode" 0)
(setq pt7 (getpoint "\Pick pt on pit side : "))
(setq ang (angle pt1 pt2))
(setq ang5 (angle pt2 pt7))
(setq diffang (- ang ang5))
(if (> diffang 1.5707) 
(setq ang2 (- ang 1.570796))
(setq ang2 (+ ang 1.570796))
)
(setq ang3 (+ ang 3.1415926))
(setq ang4 (- ang 1.570796))
(setq pt3 (polar pt1 ang length))
(setq pt4 (polar pt3 ang2 width))
(setq pt5 (polar pt4 ang3 length))

(command "pline" pt1 pt3 pt4 pt5 "c")
(setq pt6 (polar pt1 ang 50.0))
(command "offset" 0.1 pt4 pt6 "")
(setvar "osmode" oldsnap)
(setvar "clayer" oldlayer)
(princ)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...