AutoCAD Lisp Problem

Discussion in 'AutoCAD' started by Lucky, Feb 8, 2004.

  1. Lucky

    Lucky Guest

    Few years ago I got this simple AutoLisp Routine and it works very
    good with AutoCAD v.12, but it doesn't works with AutoCAD 2002. I
    would be very appreciative to anyone who can answer to me what's wrong
    with this routine, because I don't know much about Autolisp.


    ;Opsti dio
    (defun opstidio ( / zidi zide)
    (setq dz (getreal "\nDebljina zida (m):"))
    (setq sv (getreal "\nSirina vrata (m):"))
    (setq pr (getint "\nDa li vrata imaju prag (1/0):")) ; 1-da
    2-ne
    (setq ld (getint "\nDa li su vrata lijeva (1/0):"))
    ; Bira se linija zida. Tacka izbora postje tacka insertovanja.
    ; Ujedno se dobija informacija o layer-u zidova
    (setq zidl (entsel "\nTacka insertovanja (na zidu):"))
    (setq ti (cadr zidl))
    (setq zidi (car zidl))
    (setq zide (entget zidi))
    (setq zidlay (cdr (assoc 8 zide)))
    (setq ugao (getangle "\n Dvije tacke za ugao:"))
    )
    ;Pronalazenje odgovarajucih tacaka na zidu i break-ovanje zida
    (defun br ()
    (command "break" ti t2)
    (command "break" t3 t4)
    )
    ;Spajanje ivica zida poslije break-ovanja
    (defun zidovi ()
    (setvar "clayer" zidlay)
    (command "line" ti t3 "")
    (command "line" t2 t4 "")
    )
    ;Pronalazenje odgovarajucih tacaka za stokove i crtanje stokova
    (defun stokovi ()
    (setq t2 (polar ti ugao sv))
    (setq ugao1 (+ ugao (/ (* 90 PI) 180)))
    (setq t3 (polar ti ugao1 dz))
    (setq t4 (polar t3 ugao sv))
    (setq stolay (getstring "\nLayer stolarije <STOLARIJA>:"))
    (if (= stolay "") (setq stolay "stolarija"))
    (setvar "clayer" stolay)
    (setq t7 (polar ti ugao 0.05))
    (setq t8 (polar t7 ugao (- sv 0.1)))
    (setq t5 (polar t7 ugao1 (+ (/ dz 2) 0.025)))
    (setq t6 (polar t5 ugao (- sv 0.1)))
    ;Lijevi stok
    (command "line" (polar ti ugao1 (+ (/ dz 2) 0.025)) t5
    (polar t7 ugao1 (- (/ dz 2) 0.025))
    (polar ti ugao1 (- (/ dz 2) 0.025)) "")
    ;Desni stok
    (command "line" (polar t5 ugao (- sv 0.05)) t6 "")
    (command "line" (polar t2 ugao1 (- (/ dz 2) 0.025))
    (polar t8 ugao1 (- (/ dz 2) 0.025)) t6 "")
    )
    ;Crtanje praga
    (defun prag ()
    (if (= pr 1) (command "line" t5 t6 ""
    command "line" (polar t7 ugao1 (- (/ dz 2)
    0.025))
    (polar t8 ugao1 (- (/ dz 2)
    0.025)) ""))
    )
    ;Crtanje lijevog krila
    (defun krilo1 ()
    (setq t9 (polar t5 ugao 0.02))
    (setq t10 (polar t9 ugao1 (- sv 0.12)))
    (setq t11 (polar t5 ugao1 (- sv 0.12)))
    (command "line" t5 t9 t10 t11 t5 "")
    (setq ugao2 (+ ugao (/ (* 45 PI) 180)))
    (setq t12 (polar t9 ugao2 (- sv 0.12)))
    (command "arc" t6 t12 t10)
    )
    ;Crtanje desnog krila
    (defun krilo0 ()
    (setq t9 (polar t5 ugao (- sv 0.12)))
    (setq t10 (polar t9 ugao1 (- sv 0.12)))
    (setq t11 (polar t6 ugao1 (- sv 0.12)))
    (command "line" t6 t9 t10 t11 t6 "")
    (setq ugao2 (+ ugao (/ (* 135 PI) 180)))
    (setq t12 (polar t9 ugao2 (- sv 0.12)))
    (command "arc" t10 t12 t5)
    )
    ;Pokazivac za crtanje krila
    (defun krilo ()
    (if (= ld 1) (krilo1) (krilo0))
    )
    ;Osa na kojoj se ispisuje sirina i visina vrata
    (defun osa ()
    (setq t13 (polar ti ugao (/ sv 2)))
    (command "line" t13 (polar t13 ugao1 sv) "")
    (command "line" t13 (polar t13 (- ugao (/ (* 90 PI) 180)) 0.15)
    "")
    (command "circle" (polar t13 (- ugao (/ (* 90 PI) 180)) 0.26)
    0.11)
    )
    ;Glavna funkcija
    (defun C:VR (/ oldlay oldech oldblp zidl zidlay dz sv ti ugao
    t2 t3 t4 ugao1 x5 y5 t5 t6 t7 t8 pr ld t9 t10 t11 ugao2
    t12)
    (setq oldlay (getvar "clayer"))
    (setq oldech (getvar "cmdecho"))
    (setq oldblp (getvar "blipmode"))
    (opstidio)
    (setvar "cmdecho" 0)
    (setvar "blipmode" 0)
    ; (br)
    ; (zidovi)
    (stokovi)
    (prag)
    (krilo)
    (osa)
    (br)
    (zidovi)
    (command "redraw")
    (setvar "clayer" oldlay)
    (setvar "blipmode" oldblp)
    (setvar "cmdecho" oldech)
    )
     
    Lucky, Feb 8, 2004
    #1
  2. Lucky

    bestafor Guest

    HiHo;
    I don't know what language the program is in but
    R2002 has a good lisp editor "vlid" that will show
    any problems. BTW, what language is it?
    Also I have had problems with the osnap settings
    and some old lisp programs.
    You might try setting the "osmode" & "OSNAPCOORD"
    to zero. That fixed some of my old programs.
     
    bestafor, Feb 8, 2004
    #2
  3. Looks like an door insertion lisp in "Serbo-Croatian".
    I have the vocabulary of a 3 year old in Serbian, and I recognize many of
    the words.
     
    Michael Bulatovich, Feb 8, 2004
    #3
  4. Yes, it is serbian...
     
    Sinisa Knezevic, Feb 9, 2004
    #4
  5. Lucky

    Bill DeShawn Guest

    What is it supposed to do? I can´t read this language. Can you take the
    time to translate it?
     
    Bill DeShawn, Feb 12, 2004
    #5
  6. Lucky

    Bill DeShawn Guest

    Can you please translate it? I don´t think this "inserts" the door. I
    think it draws it..
     
    Bill DeShawn, Feb 12, 2004
    #6
  7. Lucky

    Bill DeShawn Guest

    It seems to work, but it does bomb close to the end, and it may be because
    I´m entering values that are not compatible with drawing the objects
    required. I really need this routine translated if you want me to fix it.
     
    Bill DeShawn, Feb 12, 2004
    #7
  8. My mistake. Looking at the code it does seem to draw a bit.
    How well could a three-year old explain to you the prompts in an English
    lisp routine?
    Let's see....it seems to prompt for:

    thickness of wall (zid, pl. zidi)
    (width?thickness?) of door(vrata)
    do the doors have ?something? (prag, pl. praga)
    are the doors left (levi/levo)

    then has comments:

    picks the wall lines
    something about inserting
    something about getting the layer info from the same pick

    more prompts:

    pick(?) insert on wall
    two picks for something at the getang line

    then theres a bunch of simple subroutines to

    break the walls
    clean up the walls
    draw the ?frames? contains comments for the left ?frame? and the right
    ?frame? ?(stok, pl. stokovi)?

    more subroutines:

    to draw the something (praga?)
    to draw the left "wing" (lijevi/lijevog krilo)
    to draw the right "wing" (desni/desnog krilo)
    one to trigger either the left or the right "wing" subroutine (krilo1 or
    krilo2)

    then the main function "VR" (glavna funkcija)

    Miko tired now. Miko go sleep.
    --

    MichaelB
    www.michaelbulatovich.com

    PS a complication in reading this stuff is that there are 30 letters in the
    two versions of their alphabet, many of which lose there do-hickeys on an
    english computer keyboard, so you read it ten times before you realise they
    mean "sh" not "s" and you actually KNOW that word.
     
    Michael Bulatovich, Feb 12, 2004
    #8
  9. Lucky

    Bill DeShawn Guest

    OK, Miko, I'll check it out tonight after work (that is if no personal major
    roadblocks manifest themselves).
     
    Bill DeShawn, Feb 12, 2004
    #9
  10. Lucky

    Lucky Guest

    Thank's to all of you for your suggestions. I have had to learn basic
    skills of AutoLisp and I have solved my problem. That was classical
    problem with brackets.
     
    Lucky, Feb 17, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.