Sorry to bug you again guys, lol, but another problem arose and I can't figure it out...
My program works sometimes but not all the time now. Every couple of tries it will work but most of the time it returns "bad argument type: VLA-OBJECT nil". It was working yesterday for every drawing I did it on and it now it doesn't even matter which drawing I'm using it on, sometimes it works, sometimes it doesn't. The batch lisp thing that you guys showed me works great though.
Here's my code, but the functions GetExcel, GetCell, OpenExcel, PutCell, & CloseExcel, are functions that i got from a website that I got a long time ago to make it easier to place information and get information from excel sheets. They've always worked before so I don't think those are the problems.
The basic premise of this is that it goes into the dwg, figures out which of my companies title blocks we used, and then gets the information out of it and sets it onto the last line of an excel sheet. The company that we do work for has horrific standards, hence the reason that I need it to look for so many variations of title blocks and attributes.
Any ideas?
;-------------------------------------------------------------------------------
; DwgLogin - Records Data to Excel Sheet for Later Use
;-------------------------------------------------------------------------------
(defun c:DwgLogin()
(vl-load-com)
(setq CurrentRow 2)
(setq root (getvar "DWGPREFIX"))
(setq xlFile (strcat root "DrawingLogin.xls"))
(GetExcel xlFile "Sheet1" "F100")
(Setq TitleCheck (GetCell "A1"))
(if (/= TitleCheck "Dwg. Number")
(progn (OpenExcel xlFile "Sheet1" nil)
(PutCell "A1" (list "Dwg. Number" "Sheet" "File #" "Desc. 1" "Desc. 2" "Rev."))
(CloseExcel xlFile)))
(while (/= "" (GetCell (strcat "C" (ITOA CurrentRow))))
(Setq CurrentRow (+ CurrentRow 1)))
(OpenExcel xlFile "Sheet1" nil)
(PutCell (strcat "C" (ITOA CurrentRow)) (substr (GetVar "DwgName") 1 15))
(CloseExcel xlFile)
(If (/= nil (ssget "_X" (list '(0 . "INSERT") (cons 2 "S-TITLE"))))
(setq TitleBlock "S-TITLE")
); **END IF**
(if (/= nil (ssget "_X" (list '(0 . "INSERT") (cons 2 "DTITLE"))))
(setq TitleBlock "DTITLE")
); **END IF**
(if (/= nil (ssget "_X" (list '(0 . "INSERT") (cons 2 "TITLE"))))
(setq TitleBlock "TITLE")
); **END IF**
(setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 TitleBlock)))) ; RETURNS SS CODE
(if (not ss) (quit))
(OpenExcel xlFile "Sheet1" nil)
(setq Edata (entget (setq e (ssname ss 0)))) ; GETS DXF SET FOR SS CODE
(while (/= (cdr (assoc 0 Edata)) "SEQEND")
(if (= (cdr (assoc 0 Edata)) "ATTRIB")
(cond ((= (cdr (assoc 2 Edata)) "DWGNO.") (PutCell (strcat "A" (ITOA CurrentRow)) (cdr (assoc 1 Edata)))) ; COND TO PICK ATTRIBUTES
((= (cdr (assoc 2 Edata)) "DwgNo.") (PutCell (strcat "A" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "DWGNO") (PutCell (strcat "A" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "DwgNo") (PutCell (strcat "A" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "WGNO") (PutCell (strcat "A" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "LINE2") (PutCell (strcat "D" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "LINE3") (PutCell (strcat "E" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "REVNO.") (PutCell (strcat "F" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "REVNO") (PutCell (strcat "F" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
((= (cdr (assoc 2 Edata)) "REV") (PutCell (strcat "F" (ITOA CurrentRow)) (cdr (assoc 1 Edata))))
)
)
(setq Edata (entget (setq e (entnext e))))
) ;WHILE
(CloseExcel xlFile)
)
**EDIT**: Got it to work, apparently I just needed a progn in the then section of an if statement. I don't know why it would work on some and not others, but oh well. Thanks everybody, couldn't have gotten this done without yall.