Run a another lisp program inside a lisp program

Discussion in 'AutoCAD' started by larry, Aug 20, 2004.

  1. larry

    larry Guest

    SURE I THINK IT (c:lisp_command) IF IT'S define (defun c:lisp_command ())
    or if it's define (defun lisp_command ()) it will be (lisp_command)
     
    larry, Aug 20, 2004
    #1
  2. larry

    Paul Turvill Guest

    (defun C:BunchofCommandsandFunctions ( )
    (function1)
    (function2)
    (C:Command1)
    (C:Command2)
    (function3)
    ... etc
    )
     
    Paul Turvill, Aug 20, 2004
    #2
  3. larry

    larry Guest

    after you load it, the command will be "save_drawline"

    (defun c:save_drawline ()
    (line-draw)
    (c:saveafter))

    (defun c:saveafter ()
    (command "qsave")
    (prompt "\n Your Drawing is now save")
    (princ))

    (defun line-draw (/ acadDocument mspace point1 point2 myLine)

    (setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))

    (setq mspace (vla-get-modelspace acadDocument))

    (setq point1 (getpoint "Specify First Point: "))

    (setq point2 (getpoint "Specify next point: " point1))

    (setq myLine (vla-addline mspace (vlax-3d-point point1)(vlax-3d-point
    point2))))
     
    larry, Aug 20, 2004
    #3
  4. Is it possible to run several other lisp in the middle of a lisp program?
     
    Leonard Johnson, Aug 20, 2004
    #4
  5. larry

    Paul Turvill Guest

    Look again at my example. You can't use (command) with LISP functions, even
    if they are prefixed with C:. Replace
    (command "sync2")
    with
    (C:sync2)

    Beware, however, since the (defun ...) for your sync2 command is
    meaningless. It calls two non-existent functions, (m) and (2540). If you
    want to define a *function* that uses argumentss, try something like this,
    and do it *outside* of your main LISP routine:

    (defun sync2 arg1 arg2)
    (<<code here to process arguments)
    (passed to arg1 and arg2>>)
    );;end of defun

    then call sync2 with (for example)
    (sync2 "m" 2540)
    where the string "m" and the integer 2540 will be substituted for arg1 and
    arg2, respectively. Sorry I can't supply any better code for the sync2
    function, since I have absolutely no idea what it is you want to do with "m"
    and 2540.
    ___
     
    Paul Turvill, Aug 20, 2004
    #5
  6. how would that look in a actual program? I am new to Autolisp.
     
    Leonard Johnson, Aug 20, 2004
    #6
  7. It tells me my lisp routine is unknown? Here is what I have.

    (command "tilemode" "1")
    (command "xref" "d" "*")
    (command "tilemode" "0")
    (command "tilemode" "1")
    (command "erase" "all" "")
    (defun C:sync2 ( )
    (m)
    (2540)
    )
    (command "sync2" "m" "2540")
    (command "mpl2")
    (command "layer" "s" "lc_xref" "")
    (command "tilemode" "0")
    (command "xref" "a" "A0-FORMAT-PLAN.dwg" "0,0,0" "1" "" "0")
    (command "purge" "a" "*" "n")
    (command "purge" "a" "*" "n")
    (command "qs")
     
    Leonard Johnson, Aug 20, 2004
    #7
  8. Sorry I'm not completely following your code.

     
    Leonard Johnson, Aug 20, 2004
    #8
  9. larry

    ECCAD Guest

    Leonard,
    Your sample code would look like this:

    (defun sync2 ( var1 var2 ); send in quoted strings
    (command var1 var2)
    ); end function

    (command "tilemode" "1")
    (command "xref" "d" "*")
    (command "tilemode" "0")
    (command "tilemode" "1")
    (command "erase" "all" "")
    ;(command "sync2" "m" "2540")
    (sync2 "m" "2540"); send sync2 function "m" and "2540"
    (command "mpl2")
    (command "layer" "s" "lc_xref" "")
    (command "tilemode" "0")
    (command "xref" "a" "A0-FORMAT-PLAN.dwg" "0,0,0" "1" "" "0")
    (command "purge" "a" "*" "n")
    (command "purge" "a" "*" "n")
    (command "qs")

    However, I don't understand what the "m" and "2540" are for, and this will probably crash.

    Bob
     
    ECCAD, Aug 21, 2004
    #9
  10. the "m" is for it to select metric, and "2540" is the scale.
     
    Leonard Johnson, Aug 23, 2004
    #10
  11. The "m" is for the routine to select Metric, and "2540" is the scale.
     
    Leonard Johnson, Aug 23, 2004
    #11
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.