Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: bad argument type: FILE nil, help plz

  1. #1
    Member
    Join Date
    2007-10
    Posts
    6
    Login to Give a bone
    0

    Exclamation bad argument type: FILE nil, help plz

    I was wondering if someone could help me with an old LSP that I did not write and I know nothing of LISP code. I have an LSP that draws a tank head and has recently started erroring out for no apparent reason. I enter two values, the tank diameter and the thickness of the head, then get the error

    Command: asme1
    What is the outside diameter? 144
    What is it's thickness? .25
    ; error: bad argument type: FILE nil

    After you enter the thickness, it is supposed to ask you for an insertion point but of course it never makes it that far. Can anyone give me some advice please? It would be much appreciated. Thank You.

    I have attached the LSP, any suggestions??
    Attached Files Attached Files

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    The first thing that stands out is it is trying to find a text file, if it can't find it you will get that error when trying to read it. To see if it is able to find your file, copy/paste this to the command line.
    Code:
    (findfile "hdata.txt")
    It will either show the full path to the file, or return nil (meaning it couldn't find the file). If it can't find the file, then you need to put the file into one of the Acad's search paths.

    If that doesn't fix the problem, then post back.

  3. #3
    Member
    Join Date
    2007-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    well i think i was able to change the correct search path...when i enter what you told me to i get:

    Command:
    Command: (findfile "hdata.txt")
    "J:\\Eng\\LSP\\hdata.txt"

    so then i ran it again and got the same result:

    Command: asme1
    What is the outside diameter? 144
    What is it's thickness? .25
    ; error: bad argument type: FILE nil

    After that didnt work i tried putting the complete file path infront of the "hdata.txt", so it then read:

    (setq fp (open "J:\Eng\LSP\hdata.txt" "r"))

    and it returned with the same result:

    Command: asme1
    What is the outside diameter? 144
    What is it's thickness? .25
    ; error: bad argument type: FILE nil

    So then I was thinking that the "r" has something to do with it. There is an r a few lines above the open command line.

    (defun dxf (code elist) (cdr (assoc code elist)))


    (setq od (getreal "What is the outside diameter? "))
    (setq thk(getreal "What is it's thickness? "))


    (setq fp (open "J:\Eng\LSP\hdata.txt" "r"))

    So I removed the "r" and the r from those two lines just as a trial and error type thing, so the code looks like this:

    (defun dxf (code elist) (cd (assoc code elist)))


    (setq od (getreal "What is the outside diameter? "))
    (setq thk(getreal "What is it's thickness? "))


    (setq fp (open "J:\Eng\LSP\hdata.txt"))

    loaded the lsp with those changes and got:

    Command: asme1
    What is the outside diameter? 144
    What is it's thickness? .25
    ; error: too few arguments


    Does that "r" have anything to do with it? I am clueless...hehe

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    Change this line if you need to read 'em:

    (setq fp (open "J:\Eng\LSP\hdata.txt"))

    on this one:

    (setq fp (open "J:\Eng\LSP\hdata.txt" "r")); where "r" is means READ
    and this is a missed argument in this expression
    ______________________________________________
    And also as Robert said below use double backslashes:
    (setq fp (open "J:\\Eng\\LSP\\hdata.txt" "r"));


    ~'J'~
    Last edited by fixo; 2007-10-26 at 05:43 PM. Reason: missed doublebackslashes

  5. #5
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    Quote Originally Posted by fixo View Post
    Change this line if you need to read 'em:

    (setq fp (open "J:\Eng\LSP\hdata.txt"))

    on this one:

    (setq fp (open "J:\Eng\LSP\hdata.txt" "r")); where "r" is means READ
    and this is a missed argument in this expression

    ~'J'~
    Also, hasn't anyone noticed the missing double-backslashes?
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    Ah, thanks, the eagle eye
    I missed it out

    Cheers

    ~'J'~

  7. #7
    Member
    Join Date
    2007-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    wow, problem solved! thanks for your help guys! you rule

  8. #8
    Member
    Join Date
    2007-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    This lsp is for drawing tank saddles...everything goes great until, well...just check out the screen shots...
    Attached Images Attached Images
    Attached Files Attached Files

  9. #9
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    Usually when that happens you have an extra enter in a command prompt. What that means is there is an extra pair of double quotes. That is what looks wrong in a quick look at your code.
    Code:
    (command "arc" pt4 "e" pt2 "r" d1 "")
    (command "arc" pt5 "e" pt3 "r" d2 "")
    You should take out the last double quotes, and check all the other command calls to see that they don't have any extra enter calls.

  10. #10
    Member
    Join Date
    2007-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: bad argument type: FILE nil, help plz

    Alrighty, i took all the extra "" from the ends of the command lines, then ran the lisp and now im getting:

    Command: SADDLE
    What is the tank gallonage? 60000
    What is the tank O.D.? 144
    What is the tank shell thickness? .375
    What is the saddle height? 6
    ; error: bad argument type: stringp nil

    And once again, I have no idea what stringp means...ill upload the updated version of the code..

    Also, there were a few double "" in the middle of the command code, so i wasnt sure if i should remove those or not.

    Thanks for your help on this, much appreciated.
    Attached Files Attached Files

Page 1 of 2 12 LastLast

Similar Threads

  1. Error: bad argument type: numberp: nil
    By pogorilyi.oleg684953 in forum AutoLISP
    Replies: 0
    Last Post: 2014-12-09, 04:27 PM
  2. Bad argument type issue
    By tntdraftsol in forum AutoLISP
    Replies: 13
    Last Post: 2014-01-10, 06:11 PM
  3. Error: bad argument type: FILE "r"
    By shell2712 in forum AutoLISP
    Replies: 0
    Last Post: 2013-09-04, 08:29 PM
  4. bad argument type: lentityp nil
    By moshira_hassan in forum AutoCAD General
    Replies: 1
    Last Post: 2009-04-15, 07:09 AM
  5. Replies: 8
    Last Post: 2007-01-03, 02:32 PM

Posting Permissions

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