lisp that runs lisps

Discussion in 'AutoCAD' started by n.almeida, Feb 22, 2004.

  1. n.almeida

    n.almeida Guest

    I'm making a series of routine commands and I would like to have one command that runs all the commands.

    Also can somebody explain, or give an example, on how to give a conditional order to a certain routine.
    The example I'm working with is creating an UCS and save it. If the UCS already exists it ask if I want to replace it and stops the routine.

    Thanks a lot.
     
    n.almeida, Feb 22, 2004
    #1
  2. n.almeida

    Chip Harper Guest

    Here's an example of using a lisp to run other lisps .....

    ;;
    (setvar "cmdecho" 0)
    ;;
    (load "SysVarReset")
    (while (> (getvar "cmdactive") 0) (command pause))
    (load "SET_TEXT")
    (while (> (getvar "cmdactive") 0) (command pause))
    (load "SET_LINES")
    (while (> (getvar "cmdactive") 0) (command pause))
    (load "SET_LAYERS")
    (while (> (getvar "cmdactive") 0) (command pause))


    Concerning the conditional program...
    (if Condition
    (Then do this)
    (Else do this)
    ); End if

    If you want to do multiple items...
    (if Condition
    (progn
    (Do first thing)
    (Do second thing)
    ); End progn
    (Else do this)
    ); End if

    Beyond that you might want to post some code with a specific question.
     
    Chip Harper, Feb 22, 2004
    #2
  3. n.almeida

    n.almeida Guest

    Thanks for the quick reply.
    Here's what I'm trying to do in a simplified example

    (DEFUN C:2_aN ()
    (COMMAND "UCS" "WORLD"
    "ZOOM" "EXTENTS"
    "UCS" "3" "END" "4929,58708" "END" "1940,58959" "END" "4678,55719"
    "UCS" "SAVE" "2_aN"

    here if the 2_aN ucs doesn't exist it goes ok, but if it already exists ACAD asks if I want to replace it - I want to answer y - and the routine stops.

    I could not figure out how to use the if in this case.

    cheers.
     
    n.almeida, Feb 23, 2004
    #3
  4. n.almeida

    Jeff Mishler Guest

    How about this?

    (DEFUN C:2_aN (/ answer)
    (if (tblsearch "UCS" "2_aN")
    (progn
    (initget "Yes No" 1)
    (setq answer (getkword "\nUCS 2_aN exists, do want to replace it?
    [Yes/No]"))
    (if (= "Yes" answer)
    (progn
    (vl-load-com)
    (vla-delete
    (vla-get-usercoordinatesystems
    (vla-get-activedocument
    (vlax-get-acad-object)))
    "2_aN")
    (COMMAND "UCS" "WORLD"
    "ZOOM" "EXTENTS"
    "UCS" "3" "END" "4929,58708" "END" "1940,58959" "END" "4678,55719"
    "UCS" "SAVE" "2_aN"
    )
    )
    )
    )
    )
    (princ)
    )

    Jeff

    ACAD asks if I want to replace it - I want to answer y - and the routine
    stops.
     
    Jeff Mishler, Feb 23, 2004
    #4
  5. n.almeida

    OLD-CADaver Guest

    Look up TBLSEARCH in developer help.. You also may need to look into COND and PROGN

    TBLSEARCH will let you look for an existing atble entry (tblsearch "ucs" "2_aN")

    (if
    (/= (tblsearch "ucs" "2_aN") nil)
    (do something) ;;then
    (do something else) ;;else
    )


    If the coordinates in your example are accurate, you don't need the "END"
     
    OLD-CADaver, Feb 23, 2004
    #5
  6. n.almeida

    mmo Guest

    After the "command"-function, check the status of system varable CMDACTIVE. If it says that a command is still active, it should be the "Ucs" commnand waiting for a 'Y". Try to use:
    (if (> (getvar "cmdactive") 0) (command "Y"))
     
    mmo, Feb 23, 2004
    #6
  7. n.almeida

    n.almeida Guest

    Thank you both.
    I could figure out how both worked [and they did] and learned at once two commands. Thanks a lot!.
     
    n.almeida, Feb 23, 2004
    #7
  8. n.almeida

    n.almeida Guest

    Thank you both.
    I could figure out how both worked [and they did] and learned at once two commands. Thanks a lot!.
     
    n.almeida, Feb 23, 2004
    #8
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.