Call a Lisp function by click on icon

Discussion in 'AutoCAD' started by Tomá¹ Nohejl, Apr 20, 2004.

  1. Hello,

    My question is following: At startup I have loaded LISP application. I
    want call a function from this loaded application by clicking on my own
    icon. Does anyone know how to programm it in LISP?

    Thanks
     
    Tomá¹ Nohejl, Apr 20, 2004
    #1
  2. Tomá¹ Nohejl

    ECCAD Guest

    Tomas,
    Sure.

    Example1: Lisp program saved in file : mylisp.lsp
    with 'function' (c:myfunction).
    In .mns file, add this:
    [Load my Lisp program]^c^c(load "mylisp.lsp");myfunction
    Example2: Lisp program saved in file: mylisp.lsp
    has no C:xxx functions, just want to load it and run it..
    In .mns file, add this:
    [Load my Lisp program]^c^c(load "mylisp.lsp")
    --------------
    Notes:
    For examples above to work, you need to have the file,
    'mylisp.lsp' - somewhere on AutoCAD's search path.
    Alternately, you need a more 'formal' path to the lisp program,
    such as ..^c^c(load "c:/mypath/mylisp.lsp").
    Notice the "/", not "\" in the path.
    Also, you may need to recompile the menu - see Menuload command. Unload the menu, and reload it.

    I hope this helps..

    Cheers

    Bob Shaw
     
    ECCAD, Apr 20, 2004
    #2
  3. Tomá¹ Nohejl

    ECCAD Guest

    If coming from the ToolBar section..
    Sample:
    ID_TIMERS [_Button("Timers", TIMERS.bmp, TIMERL.bmp)]^c^c(if (not C:myfunction)(load "mylisp.lsp")) myfunction
     
    ECCAD, Apr 20, 2004
    #3
  4. Tomá¹ Nohejl

    zeha Guest

    Bob

    I do it this way

    ID_TIMERS [_Button("Timers", TIMERS.bmp, TIMERL.bmp)]^c^c(if C:myfunction(princ)(load "mylisp.lsp""Cannot loaded mylisp")) myfunction

    The (princ) return's not a nil on the command line if the function previous has been loaded.
     
    zeha, Apr 21, 2004
    #4
  5. Tomá¹ Nohejl

    ECCAD Guest

    zeha,
    That method is good also. Do you need another "(" in there ?

    Bob
     
    ECCAD, Apr 21, 2004
    #5
  6. Thank you for your answers.
     
    Tomáš Nohejl, Apr 22, 2004
    #6
  7. Tomá¹ Nohejl

    ECCAD Guest

    Tomas,
    Glad to be of help. Hope you got it working.

    Bob
     
    ECCAD, Apr 22, 2004
    #7
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.