SIMPLE LISP QUESTION

Discussion in 'AutoCAD' started by G. Willis, Sep 20, 2004.

  1. G. Willis

    G. Willis Guest

    In the lisp below I need to check if the current dimension style is "LEADER" and if not I need to set the DIMSTYLE to LEADER. I don't know how to construct the "IF" statement.

    I want to avoid the "flash" that occurs because the DIMSTYLE command causes the text window to display momentarily each time it runs so I figure I can avoid running the DIMSTYLE command at all if LEADER is already loaded, unless there is a way to set DIMSTYLE to LEADER each time the program runs without the annoying text screen flashing.

    I am using ACAD2002.

    Any help would be much appreciated.

    Garth.

    ;*AA.LSP

    (DEFUN C:AA ()
    (SETVAR "cmdecho" 1)
    (command "-LAYER" "S" "DIM" "")
    (COMMAND "ORTHO" "OFF")
    (COMMAND "OSMODE" "16417")
    (command "-DIMSTYLE" "R" "LEADER") ; this causes the "flash" which I would like to avoid
    (command "qleader" PAUSE)
    (setvar "cmdecho" 0)

    (princ))
     
    G. Willis, Sep 20, 2004
    #1
  2. G. Willis

    G. Willis Guest

    Jim,
    thanks for the quick reply but this doesn't seem to work for me.
    I get the following response:
    "Error: malformed string on input"

    garth.
     
    G. Willis, Sep 20, 2004
    #2
  3. G. Willis

    G. Willis Guest

    My bad. I must have deleted one of the quotation marks by accident.
    It works now but I made a slight modification.
    Thanks for the help!

    ;*AA.LSP

    (DEFUN C:AA ()
    (SETVAR "cmdecho" 1)
    (command "-LAYER" "S" "DIM" "")
    (COMMAND "ORTHO" "OFF")
    (COMMAND "OSMODE" "16417")
    ;(COMMAND "-DIMSTYLE" "R" "LEADER")
    (if (/= (getvar "dimstyle") "LEADER")
    (command "-dimstyle" "R" "LEADER")
    )
    (command "qleader" PAUSE)
    (setvar "cmdecho" 0)
    (princ))



    Jim,
    thanks for the quick reply but this doesn't seem to work for me.
    I get the following response:
    "Error: malformed string on input"

    garth.
     
    G. Willis, Sep 20, 2004
    #3
  4. G. Willis

    T.Willey Guest

    Try this
    (if (not (= (strcase (getvar "dimstyle")) "LEADER"))
    (command ".dimstyle" "R" "LEADER")
    )

    Tim
     
    T.Willey, Sep 20, 2004
    #4
  5. G. Willis

    Jim Claypool Guest

    Oops! That's what I get for getting in a hurry.
    Thanks for the correction.
     
    Jim Claypool, Sep 21, 2004
    #5
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.