+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Senior Member
    Using
    not specified
    Join Date
    Dec 2005
    Posts
    106

    Default got error when running LISP

    Registered forum members do not see this ad.

    Hi,

    I was wondering if i could get some help here. I'm new to AutoLISP and am still learning it.

    I wrote the following code but it kept telling me "error: bad function: "\nEnter your name"

    (defun NAME()
    (setq a (getstring ("\nEnter your name")))
    (princ (strcat "\nYou are " a))
    (princ)
    ); defun

    Have i missed anything here?

    And also, if i may ask another question, i have received a LISP file from someone. How do i run it from my autocad 2005?

    Thank you in advance

  2. #2
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    Change your code to the following.....

    Code:
    (defun c:NAME ()
    (setq a (getstring"\nEnter your name"))
    (princ (strcat "\nYou are " a))
    (princ)
    ); defun
    Start the routine by typing "name" at the command line.

    Q2.....to load the lisp routine you got from elsewhere.....type at the command prompt (load "filename"), then it should respond with the start command for the routine, just type that command at the command prompt to initiate the routine....

  3. #3
    Senior Member
    Using
    not specified
    Join Date
    Dec 2005
    Posts
    106

    Default

    Hi Allan,

    Thank you for your reply.

    In regards to Q2, I have saved the file, ZERO-Z.LSP under MyDocument in C-drive. Then, at the command prompt, i typed (load "ZERO-Z"). It didn't like it. it said "error: load failed...". Then, i tried it again by typing (load "C:\Document and Settings\users\MyDocument\ZERO-Z.LSP"). It still gave me error in loading the file. I must have done something wrong here. Wonder where i got it wrong.

    Thank you in advance

  4. #4
    Luminous Being StykFacE's Avatar
    Computer Details
    StykFacE's Computer Details
    Operating System:
    Windows 7 Ultimate 64bit
    Computer:
    Dell Precision T3500
    Discipline
    Multi-disciplinary
    StykFacE's Discipline Details
    Occupation
    BIM Manager & Design Specialist
    Discipline
    Multi-disciplinary
    Details
    Facilities engineering, involving mechanical piping, mechanical HVAC and electrical engineering.
    Using
    Revit 2013
    Join Date
    Mar 2006
    Location
    Dallas, TX - USA
    Posts
    6,497

    Default

    just type APPLOAD and find the file. or drag and drop it into AutoCAD. then type NAME to initiate.
    Last edited by StykFacE; 5th Jan 2007 at 12:10 am. Reason: changed command from LOAD to APPLOAD.
    Tannar Frampton | Facilities Engineering | Revit 2013
    Personal Projects | Fender Squier Stratocaster | Custom Smoker | Concrete Patio

  5. #5
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    First up...when you type a path in acad you must use forward slashes, not back slashes (I think, if my memory hasn't faded) also they may need to be double forward slashes (can't really remember!!!).

    Anyway, the easiest way is to place the directory where you put the lisp routine into the acad search path.....

    Tools -> Options -> Files -> Support File Search Path

    Further to the above...I place all my lisp routines in a directory C:\ACADLISP. It's a simple, quick, easy directory to find.

  6. #6
    Super Member profcad's Avatar
    Computer Details
    profcad's Computer Details
    Operating System:
    Windows Vista Ultimate
    Computer:
    Dell
    CPU:
    Dual - Six-Core Xeon
    RAM:
    12GB
    Graphics:
    NVida 4400
    Monitor:
    DUAL 22" WIDESCREEN
    Using
    Revit 2012
    Join Date
    Dec 2005
    Location
    Oklahoma City, OK
    Posts
    825

    Default

    (load "C:\Document and Settings\users\MyDocument\ZERO-Z.LSP").
    Change the \ to \\ or /

    (load "C:\\Document and Settings\\users\\MyDocument\\ZERO-Z.LSP")



    or you can type APPLOAD, then select the file using the dialog box.
    John Helton
    Professor of CAD
    Oklahoma City Community College
    Oklahoma City, OK

  7. #7
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    (the (load "filename") will work if the routine is in the support file path, otherwise it's not found. For path separators s in lisp statements, use a forward slash or a double backslask=h.

    An easier way to load a lisp routine is with the menu, Tools>>Load Application then browse to the file.

    **edit**
    beat by the prof, but at least we agree

  8. #8
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    You got in before me, Styk....

    ali888,
    There are many ways to load a lisp routine, you'll get the hang of them soon enough...

    Edit.....wow, everyone suddenly jumped in...good stuff

  9. #9
    Senior Member
    Using
    not specified
    Join Date
    Dec 2005
    Posts
    106

    Default

    Thank you all for your support.

    Yes, it works now. I go to tool -> AutoLISP -> load. I also keep the LISP file under C:\ACADLISP which is advised by Alan. I'll keep it in mind to use the right slash.

    Thank you all for your help

  10. #10
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    Registered forum members do not see this ad.

    Your welcome....if you have any problems with your learning lisp, don't hesitate to ask us....

Similar Threads

  1. And AU is Off and Running!
    By Lynn Allen's Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 28th Nov 2006, 06:51 am
  2. Replies: 0
    Last Post: 16th Oct 2006, 11:13 pm
  3. errors while running lisp
    By vivekgrs in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 9th Aug 2006, 12:49 pm
  4. First time running lisp gives unexpected outcome.
    By mafkees in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 28th Nov 2005, 06:53 am
  5. Can anyone find me the error in this lisp
    By pintech in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 4th May 2005, 01:21 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts