Help debugging

Discussion in 'AutoCAD' started by Donovan Cox, Sep 23, 2004.

  1. Donovan Cox

    Donovan Cox Guest

    I've for some reason managed to get myself in trouble by helping someone
    with the old lisp routines when my experience is rather limited. I've got
    the routine doing what I want almost. originally the routine would let you
    draw a leader line and then insert a particular block depending on the
    orientation of the leader. I've managed to get the thing to work, but on
    occasion it will make AutoCAD go into some sort of loop. the command line
    will look like it's spinning.

    this is what I'm using.

    ^C^C(command "layer" "set" "DIM" "");;(SETVAR "CMDECHO" 0);(SETQ P1
    (GETPOINT "FROM POINT: "));\_LEADER;!P1;\;;N;(SETQ P2 (GETVAR
    "LASTPOINT"));^C^C(command "layer" "set" "0");;(IF (>= (CAR P2) (CAR P1))
    (SETQ A "SYM01"));(IF (< (CAR P2) (CAR P1)) (SETQ A "SYM01L"));-Insert !A
    !P2 (GETVAR "DIMSCALE")

    this is the original
    ^C^CLAYER S DIM;;(SETVAR "CMDECHO" 0);(SETQ P1 (GETPOINT "FROM POINT:
    "));\_LEADER;!P1;\;;N;(SETQ P2 (GETVAR "LASTPOINT"));^C^CLAYER S 0;;(IF (>=
    (CAR P2) (CAR P1)) (SETQ A "SYM01"));(IF (< (CAR P2) (CAR P1)) (SETQ A
    "SYM01L"));INSERT !A !P2 (GETVAR "DIMSCALE");;0;\
     
    Donovan Cox, Sep 23, 2004
    #1
  2. Donovan Cox

    Donovan Cox Guest

    I think I found it, there was a second pair of quotation marks where I set
    my layer in the beginning
     
    Donovan Cox, Sep 23, 2004
    #2
  3. You could either eliminate that pair of quotation marks and let the second
    semi-colon after the right parenthesis finish the Layer command (which is
    how it's happening at the set-back-to-zero later), or you can keep the
    quotation marks and finish the command inside the parentheses, and eliminate
    one of the semi-colons after it (which I think "looks" cleaner).

    If I might suggest another little simplification:

    "IF" can take two resulting operations, where if the test is positive it
    does the first, and if not it does the second --
    (if (<test-condition>) (<if-true-do-this>) (<if-not-do-this>))

    So you don't need to test whether point 2 is left of point 1, because if the
    previous test comes up negative, then this will be the case. You can
    collapse your IF things together into:

    (IF (>= (CAR P2) (CAR P1)) (SETQ A "SYM01") (SETQ A "SYM01L"))

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Sep 23, 2004
    #3
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.