Exited: bad arugment type: FILE NIL

Exited: bad arugment type: FILE NIL

raceharder
Enthusiast Enthusiast
466 Views
7 Replies
Message 1 of 8

Exited: bad arugment type: FILE NIL

raceharder
Enthusiast
Enthusiast

I have a lisp that updates the info in a titleblock.  It was working and has suddenly quit.  I am getting a "Exited:  bad argument  type:  FILE NIL" when running the lisp.  Here is a copy of the code:

 

;; This code takes the last 3 digits of the filename
;; and puts them on the tag SHT_NO_1 on tb supplied
;; by Ford
;; It writes the FILE_NAME tag from the
;; system variable dwgname
;; The rest of the variables are written
;; out from a sample sheet into a file
;; called ttlblk.txt written in the homedir of
;; the drawing file


;;for kits added 4/17/08
(defun C:NG_KFTBIN ( / unit)
(setq unit "1A10")
(FTB UNIT)
)

 

(defun C:NGK ( / unit)
(setq unit "1A10")
(FTB UNIT)
)

 

;;for pneumatics
(defun C:NG_PFTBIN ( / unit)
(setq unit "1A7")
(FTB UNIT)
)

(defun C:NGP ( / unit)
(setq unit "1A7")
(FTB UNIT)
)

;; for water
(defun C:NG_WFTBIN ( / unit)
(setq unit "1A8")
(FTB UNIT)
)

(defun C:NGW ( / unit)
(setq unit "1A8")
(FTB UNIT)
)


;; SHORTCUT FOR LEE
(defun C:NG_IN ()
(print " in in")
(C:FTBIN)
)
;; for electric

(defun C:NGFTBIN ( / unit)
(PRINT "IN FTBIN")
(setq unit "1A5")
(FTB UNIT)
)


(defun FTB (UNIT / dwgnme homedir desclgth dwglen startpnt dwgnm len_dwgnm)


(setq dwgnme (getvar "DWGNAME"))
(setq homedir (getvar "DWGPREFIX"))

(setq ttlfil (strcat homedir "NGtitleblk.txt")
f (open ttlfil "r")
)
(print "dwgname is ")(print dwgnme)
(print "homedir is ")(print homedir)
;(print "ttfil is ")(print ttlfil)
; ;(setq len_dwgnm 3) ;; char needed for last digits to get drawing num -- 3 usually
; ;; 4 when you have an A, B or C in name
;
; ;(print "homedir is ")(print homedir)
; ;(print "ttfil is ")(print ttfil)
; ;(print "f is ") (print f)
; ;(command "style" "standard" "ford_ba" "" "" "" "" "" "") ;make sure that standard is set to Ford font
;
; (setq desclgth (strlen DWGNME))
; ;(PRINC DESCLGTH)
; (setq dwglen (- desclgth 4)) ; length without .dwg -- 4 digits
; (setq startpnt (- dwglen 2)) ; puts you at the start of the number part of drawing name
; (setq DWGNM (substr DWGNME startpnt 3)) ;sheet number digits are usually 3
;
; ; (setq len_unit 😎 ; puts you at the start of the number part of drawing name
; (setq len_unit 😎 ; puts you at the start of the number part of drawing name
; (setq unit_stpnt (- dwglen (- len_unit 1 ))) ; puts you at the start of the number part of drawing name
;
; ;(print "abefore first cond dwgnm is ")(print dwgnm)
; ;; ADDED THIS SECTION BECAUSE WE HAVE DRAWINGS WITH A,B,C - PER MIKE
;
; (cond
; ((= "A" (strcase (substr DWGNM 3 1)))(print (substr DWGNM 3 1))
; (setq len_dwgnm 4)(setq startpnt (- startpnt 1)))
; ((= "B" (strcase (substr DWGNM 3 1)))(print (substr DWGNM 3 1))
; (setq len_dwgnm 4)(setq startpnt (- startpnt 1)))
; ((= "C" (strcase (substr DWGNM 3 1)))(print (substr DWGNM 3 1))
; (setq len_dwgnm 4)(setq startpnt (- startpnt 1)))
; ((= "D" (strcase (substr DWGNM 3 1)))(print (substr DWGNM 3 1))
; (setq len_dwgnm 4)(setq startpnt (- startpnt 1)))
;
;
;
; );END COND
;; 12/2009 -- changed file name from the file name to just the last 8 digits with the .dwg extension
; (setq UNITNM (strcase (substr DWGNME unit_stpnt len_unit))) ;sheet number digits are usually 3
;
; (setq DWGNM (strcase (substr DWGNME startpnt len_dwgnm))) ;sheet number digits are usually 3
; (print "before strip dwgnm") (print DWGNM)
;
; ;;strip out leading zeros for entry into the sheet attribute
; (cond
; ((= "00" (substr DWGNM 1 2)) (setq DWGNM (substr DWGNM 3 (- len_dwgnm 2))))
; ((= "0" (substr DWGNM 1 1)) (setq DWGNM (substr DWGNM 2 (- len_dwgnm 1))))
;
; );end cond
;(setq DWGNM (strcat UNIT DWGNM)) ;add the 1A5 for electrical
(print "dwgnm after cat is ")(print dwgnm)

;call the tags that we choose to keep the
;same in all drawings that we wrote out to
;ttlblk.txt in Ford_TB_OUT
(print "before call to TAGFIND")
(setq newv (read-line f))
(print "first newv is")(print newv)
(TAGFIND "TITLE_LINE1" newv)
(setq newv (read-line f))
(print "2nd newv is")(print newv)
(TAGFIND "TITLE_LINE2" newv)
(setq newv (read-line f))
(TAGFIND "TITLE_LINE3" newv)
(setq newv (read-line f))
(TAGFIND "TITLE_LINE4" newv)
(setq newv (read-line f))
(TAGFIND "DESIGN_SOURCE" newv)
(setq newv (read-line f))
;(print "first newv before ttl_sht is")(print newv)
(TAGFIND "TTL_SHT" newv)
(setq newv (read-line f))
;(print "first newv before DES_BY is")(print newv)

(TAGFIND "DES_BY" newv)
(setq newv (read-line f))
(TAGFIND "DET_BY" newv)
(setq newv (read-line f))
(TAGFIND "DATE_TB" newv) ;GAVE A NEW TAG NAME -- MIGHT CONFLICT WITH SYSTEM NAME
;(TAGFIND "DATE" newv) ;GAVE A NEW TAG NAME -- MIGHT CONFLICT WITH SYSTEM NAME
(setq newv (read-line f))
(TAGFIND "PROGRAM_NAME" newv)
(setq newv (read-line f))
(TAGFIND "CHK_BY" newv)
(setq newv (read-line f))
(TAGFIND "ZF_NO_1" newv)
(setq newv (read-line f))
;;added variables 12/2009 for NextGen Titleblock
(print "before reading new variables and newv is ")(print newv)
(TAGFIND "BUILD_SOURCE" newv)
(setq newv (read-line f))
(TAGFIND "SAFETY" newv)
(setq newv (read-line f))
;(TAGFIND "DIV_NAME" newv)
;(setq newv (read-line f))
;(TAGFIND "PLANT_NAME" newv)
;(setq newv (read-line f))
;(TAGFIND "LOC_ACT" newv)
;(setq newv (read-line f))
(TAGFIND "BUILD_STATUS" newv)
(setq newv (read-line f))
(TAGFIND "SHOP_ORDER_RIGHT" newv)
(print "before last read ")
(setq newv (read-line f))
(print "after last Read newv is ")(print newv)
(TAGFIND "SHOP_ORDER_LEFT" newv)
(print "after last read newv is ")(print newv)

 

 

;;these 2 tags are taken from system variables
;(setq dwgnme (strcat homedir dwgnme))
(TAGFIND "FILE_NAME" dwgnme);dwgname
;(TAGFIND "FILE_NAME" UNITNM);dwgname

(TAGFIND "SHT_NO_1" dwgnm) ;;last 3 digits with leading zeros removed
(TAGFIND "DWGSECTION1" unit) ;;last 3 digits with leading zeros removed

;(print "at end of TAGFIND")
(close f)


) ; end dname

 


;;
;; Globally Modifies Tag Values, All Blocks
;;===========================================================
(defun TAGFIND (tagname newv / tagname ss1 len count bn en el found attstr)
;=================create selection set=======================

(setq ss1 (ssget "x" '((0 . "insert") (66 . 1)))
len (sslength ss1)
count 0
)
(repeat len
(setq bn (ssname ss1 count) ;Block Name
en (entnext bn) ;Entity Name
el (entget en)) ;Entity List


;=================loop thru block entities===================

(while (and (= "ATTRIB" (dxf 0 el))
(/= "SEQEND" (dxf 0 el)))
;(print "(dxf 2 el) before if is ")(print (dxf 2 el))
(if (= (dxf 2 el) (strcase tagname))
(progn

;print "(dxf 2 el) is ")(print (dxf 2 el))
(setq attstr (dxf 1 el))
;print "(dxf 1 el) is ")(print (dxf 1 el))
;(print "attstr is ")(print attstr)
(setq el (subst (cons 1 newv) (assoc 1 el) el))

(entmod el) ;Modify List
(entupd bn) ;Update Screen
(setq found "yes") ;Found Tag?
);progn
) ;if
(setq en (entnext en)
el (entget en))
);while
(setq count (1+ count))
;(print "before repeat")
) ;repeat
(if (/= found "yes")
(princ "\nTag Not Found.")
)

;(princ "at end of TAGFIND")
);defun TAGFINDt.lsp

 

 

 

;======================dxf function==========================
(defun dxf (code elist)
(cdr (assoc code elist))
);dxf
(princ)
;============================================================
QSAVE

 

It appears that the lisp runs through the line I have made the text red on above.

 

Any thoughts or ideas on why this is happening would be greatly appreciated.

 

RH

0 Likes
467 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

It almost certainly means it did not find the file that you intended to set into the 'f' variable.  Have you changed file folder structure, or changed naming format, or something?

 

You've commented out the line that prints what that is -- if you have it do that again, does it show the right file name?

Kent Cooper, AIA
0 Likes
Message 3 of 8

raceharder
Enthusiast
Enthusiast

Thanks for your reply and assistance.  Here is a copy of the command line when running the lisp.  Weird thing is, I am now getting a different error as you can see.  The only change I made to the lisp is to un comment the line showing what the file is.

0 Likes
Message 4 of 8

raceharder
Enthusiast
Enthusiast

As most others, I am new to coding lisps and scripts and inherited items that were previously maintained by someone else.

 

0 Likes
Message 5 of 8

raceharder
Enthusiast
Enthusiast

We did change our network structure somewhat and eliminated the drives that these lisps were originally housed on.  At one point, this was working after the move.

0 Likes
Message 6 of 8

raceharder
Enthusiast
Enthusiast

sorry, forgot the command line text. 

 

Command: NGFTBIN
"IN FTBIN"
"dwgname is "
"154ZF-20002738_10_5195.dwg"
"homedir is "
"C:\\Users\\raceharder\\Documents\\race\\work files\\Ford\\U71x\\Hood\\Decomm\\Affected\\"
"ttfil is "
"C:\\Users\\raceharder\\Documents\\race\\work files\\Ford\\U71x\\Hood\\Decomm\\Affected\\NGtitleblk.txt"
"dwgnm after cat is "
nil
"before call to TAGFIND"
"first newv is"
"GUARDLOGIX: REF REV. 3.00"
"2nd newv is"
"U553/554 2022_U717/718 2025"
Tag Not Found.
"before reading new variables and newv is "
" GPS"
"before last read "
"after last Read newv is "
"test"
"after last read newv is "
"test"
Exited: bad DXF group: (1)

0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant

@raceharder wrote:

....

"dwgnm after cat is "

nil
....
Tag Not Found.
....
Exited: bad DXF group: (1)


So now it's a different Error message than in the Topic heading....

 

I don't know whether the blue part above tells you anything, but I expect the red part should.

Kent Cooper, AIA
0 Likes
Message 8 of 8

raceharder
Enthusiast
Enthusiast

Yes it is.   So this lisp loads when acad.lsp loads when acad opens.  I have set acadlspasdoc to 1 so that acad.lsp loads with each file.  When I run ngftbin I get the 1st error I listed:  Exited:  bad argument type:  FILE NIL.  If I appload the ngftbin.lsp I then get a different error (Exited: bad DXF group: (1))

 

I don't understand why that would be.

 

0 Likes