+ Reply to Thread
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 50

Thread: Lisp program

  1. #1
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2007
    Location
    Brisbane Australia
    Posts
    441

    Default Lisp program

    Registered forum members do not see this ad.

    Please help me on this lisp program
    Code:
    ; filename tee.lsp
    ;This prompts you for Dimensions as per Iplex catalogue
    ;then draws a Tee pn1 equal and uequal branch
    ;written by Donald Christensen 7/march/2007
    (defun c:tee ()
    (graphscr)
    ;
    ; promp for input
    ;
    (setq hDN(getdist"\nHeader DN? "))
    (setq dDN(getdist"\nBranch DN? "))
    (setq b(getdist"\nHeader Length B? "))
    (setq h(getdist"\nBranch Length H? "))
    ;
    ;Below is wrong. I copied it from another program I wrote before.
    ;I haven't written lisp for 12 years. I was a newbie then, now I know even less
    ;I included it because this is the simple structure I understood then
    ;and may jog memories as I learn lisp again
    ;
    ;
    ;
    (setq radd(list(*(car wth)2)(*(cadr wth)2))) 
    (setq a(list(-(car orrigin)(/ ht 2))(-(cadr orrigin)(/ wth 2))))
    (setq b(list(+(car p1)ht)(cadr p1)))
    (setq c(list(car p2)(+(cadr p2)wth)))
    (setq d(list(-(car p3)ht)(cadr p3)))
    ;
    (setq e(list(+(+(car p1)wt)wt)(cadr p1))) 
    (setq f(list(car p1)(+(+(cadr p1)wt)wt)))
    (setq g(list(-(-(car p2)wt)wt)(cadr p2))) 
    (setq h(list(car p2)(+(+(cadr p2)wt)wt)))
     
    (COMMAND "_pline" o1 "A" "ce" c1 o2 "l" o3 "a" "ce" c2 o4 "l" o5 "a" "ce" c3 o6 "l" o7 "a" "ce" c4 o8 "l" o1 "")
    (COMMAND "_pline" i1 "A" "ce" c1 i2 "l" i3 "a" "ce" c2 i4 "l" i5 "a" "ce" c3 i6 "l" i7 "a" "ce" c4 i8 "l" i1 "")
     
    This is sintax is wrong but describes what I want to do
    if hDN = 80 then hDIA = 99
    if hDN = 100 then hDIA = 122
    if hDN = 125 then hDIA = 140
    if hDN = 150 then hDIA = 177
     
    if bDN = 80 then bDIA = 99
    if bDN = 100 then bDIA = 122
    if bDN = 125 then bDIA = 140
    if bDN = 150 then bDIA = 177
    ;I know this repeats and it is sloppy but it is easy to follow
     
    set layer defpoints color 55
    line cl1, cl2
    line cl3 0,0
    set layer o color bylayer
    pline a, b, c, d, e, f
    pline 0,0 f,g, h, a, 0,0
     
    )
    tee.dwg


    Sorry for posting so often with so many questions
    I'm in panic mode because I'm learning Autocad again.
    I'm at work and feel clumbsy with this version
    It's so different to a version I'm familure with

    I'm trying to do 2 things

    1. draw blocks (this lisp program)
    2. customize Autocad

  2. #2
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    Just having a quick look at it, you are using variables that have not previously been defined.....that would definitely cause problems...

    Could you post the Iplex tee sizes drawing (from their catalogue) up so I can have a look at it.....I may be able to have a closer look at your code at lunch time.

    I couldn't find our Iplex catalogue....sorry.

  3. #3
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2007
    Location
    Brisbane Australia
    Posts
    441

    Default

    Sorry

    I attached a drawing of a tee
    When I previewed my thread, it was there

    I guess it didn't come out

  4. #4
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    This is sintax is wrong but describes what I want to do
    if hDN = 80 then hDIA = 99
    if hDN = 100 then hDIA = 122
    if hDN = 125 then hDIA = 140
    if hDN = 150 then hDIA = 177
    I think you can make dotted pairs list:
    Code:
    (setq parLst '((80 . 99)(100 . 122)(125 . 140)(150 . 177)))
    And extract datas. For example:
    Code:
    Command: (cdr(assoc 80 parLst))
    99
    Command: (cdr(assoc 100 parLst))
    122
    You can try it in command line.

    In my opinion in this case there is no sense to draw blocks by lisp program. Them to draw manually easier, however by means of the program it is possible to automate their insert. However you certainly can make it with a view of training.

  5. #5
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2007
    Location
    Brisbane Australia
    Posts
    441

    Default

    Quote Originally Posted by ASMI View Post
    In my opinion in this case there is no sense to draw blocks by lisp program. Them to draw manually easier, however by means of the program it is possible to automate their insert. However you certainly can make it with a view of training.
    I'd like to draw by lisp. This is a program to draw a pipe tee. However, I will use it as a template for other lisp programs. I have about 1 thousand blocks to draw.

    Also, I can't think of a better way to learn lisp again.

    I think I can write 90% of the program

    2 more questions. (sorry for being think)

    is parList a variable? Can I change it to hDN?

    do I write:

    (setq hDN(getdist"\nHeader DN? "))

    (setq hDN '((80 . 99)(100 . 122)(125 . 140)(150 . 177)))

    ; example
    ; if hDN user input is 80 then hDN = 99
    ;
    ;
    ;
    ;

    is car the x yalue and cadr the y value?

  6. #6
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    (setq hDN(getdist"\nHeader DN? "))
    If you are going to type in the text, then change this to...
    (setq hDN(getreal"\nHeader DN? "))

    As for car and cadr, use the following e.g.'s......

    (car ’(a b c)) returns A
    (car ’((a b) c)) returns (A B)

    (cdr ’(a b c)) returns (B C)
    (cdr ’((a b) c)) returns (C)

    (setq pt (cdr (assoc 10 data)))
    (setq ptx (car pt) pty (cadr pt) ptz (caddr pt))
    (setq pt (list ptx pty 0))






  7. #7
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2007
    Location
    Brisbane Australia
    Posts
    441

    Default

    (setq hDN '((80 . 99)(100 . 122)(125 . 140)(150 . 177)(200 . 232)(250 . 286)(300 . 345)(375 . 426)(450 . 507)(525 . 587)(600 . 667)(675 . 122)(750 . 826)(900 . 923)(1000 . 1025)(1200 . 1229)(1400 . 1433)(1600 . 1637)(1800 . 1841)(2000 . 2045)(2200 . 2249)(2400 . 2453)(3000 . 3065)))
    (setq dDN '((80 . 99)(100 . 122)(125 . 140)(150 . 177)(200 . 232)(250 . 286)(300 . 345)(375 . 426)(450 . 507)(525 . 587)(600 . 667)(675 . 122)(750 . 826)(900 . 923)(1000 . 1025)(1200 . 1229)(1400 . 1433)(1600 . 1637)(1800 . 1841)(2000 . 2045)(2200 . 2249)(2400 . 2453)(3000 . 3065)))

    Is there a limit to the length?

  8. #8
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    I'm afraid you have totally lost me.....I have no idea what you are trying to do.......

  9. #9
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    There may be a limit to the number of items in a list but it may be millions or more so don't worry

    You don't need to create 2 identical lists; if for some reason you need two equal variables just use;

    (setq hDN '("humongous list"))
    (setq dDN hDN)

  10. #10
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    Registered forum members do not see this ad.

    Thanks Carl.....I was hoping you'd come in on this.

    From what I can gather......(80 . 99).....the 80 is the internal diameter (mm) of one branch, and the 99 is the external diameter of that branch ?????

    I don't understand why he's setting up lists like this

Similar Threads

  1. Which program would be best?
    By ChadPoehland in forum Autodesk Software General
    Replies: 0
    Last Post: 15th Jan 2007, 06:56 pm
  2. Need LISP program to select all objects in layer
    By Vigilante in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 30th Nov 2006, 08:35 pm
  3. Making a lisp a permanent part of the program?
    By New2CADmike in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 24th Sep 2006, 12:15 am
  4. a question about my lisp program for ploting parabola
    By winglj in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 24th Feb 2006, 03:23 am
  5. How do I run this .VLX program?
    By Cadastrophic in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 2nd Nov 2004, 06:54 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts