Ciaran_mccreary Posted July 31, 2013 Posted July 31, 2013 Hi, Need a little help with some modification of an existing LISP file that I have found. The list pull's the linelist XDATA from cadworx. I am not in anyway a LISP writer but wonder if this could be done easily enough. - Instead of writing to a *.TXT file could this be written to as *.XLS - Could the lisp prompt for save location? Instead of location of current of *.dwg - If I could get it to Excel could I then get "line-list" to the first column and the *.dwg number to the 2nd column and maybe date to the 3rd column? Below is the code I found any help would be great. ;C Greg Silva 1/03/07 ;c:getlin Get Linenumber ;This program is used to go thru all the Cadworx Xdata and grab the linenumbers that are used in ;the current drawing then save out to a file that is located in the same directory as the current ;file with a .txt extension. it also adds the name of the drawing infront of each line number so you can ;combine into a spreadsheet and keep track of what Model each line goes thru. (defun c:getlin (/ a b counter first getall item lnum-name lnum-namelist openfile second sscount vdwgname vdwgname1 vdwgprefix xdata xdata-list) (Setq getall (ssget "x")) (Setq sscount (sslength getall)) (setq counter 0) (setq lnum-namelist (list)) (repeat sscount (setq item (ssname getall counter)) (setq item (vlax-ename->vla-object item)) (setq xdata (vla-getxdata item "CPD1" 'first 'second)) (if First (progn (setq xdatanum (vlax-safearray->list first)) (setq xdata-list (vlax-safearray->list second)) (setq lnum-name (nth 5 xdata-list)) (setq lnum-name (vlax-variant-value lnum-name)) (if (not (member lnum-name lnum-namelist)) (progn (if lnum-namelist (setq lnum-namelist (append (list lnum-name) lnum-namelist)) (setq lnum-namelist (list lnum-name)) ) ) ) )) (setq counter (+ 1 counter)) ) (princ) (if lnum-namelist (progn (setq vdwgname (getvar "dwgname")) (setq vdwgname1 (strcat (vl-filename-base vdwgname) ".xls")) (setq vdwgprefix (getvar "dwgprefix")) (setq openfile (open (strcat vdwgprefix vdwgname1) "w")) (mapcar '(lambda (a) ;(setq b (strcat vdwgname "," a)) (write-line a openfile) ) lnum-namelist ) )) (Close openfile) (setq openfile nil) (princ) ) (princ "\ECE Design 2011") Quote
BIGAL Posted August 4, 2013 Posted August 4, 2013 The file path is controlled by the 3 lines (setq vdwgname (getvar "dwgname")) ; drawing name (setq vdwgname1 (strcat (vl-filename-base vdwgname) ".xls")) ;get dwg name (setq vdwgprefix (getvar "dwgprefix")) ; get where is dwg (setq openfile (open (strcat vdwgprefix vdwgname1) "w")) ;open a file for writing This would be a hard coded file name (setq openfile (open "C:\\acadtemp\\myfile.txt" "w")) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.