Thank you Ymg the first part of the lisp (P,X,Y,Z) now work perfect.
Can you help me little with the second (P,X,Y)
;;----------------------=={ Text File to Table }==----------------------;;
;; ;;
;; Prompts the user to select a text file and generates an AutoCAD ;;
;; Table at the point specified, representing the file data. ;;
;;----------------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;;
;;----------------------------------------------------------------------;;
(defun c:txt2tab2 ( / *error* del des hdl ins lin lst txt )
(setq ttl nil ;; Table Title (nil for no title)
hdl '("A/A" "X" "Y") ;; Table Headings
del "," ;; Data Delimiter String
)
(defun *error* ( msg )
(if (= 'file (type des)) (close des))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
(if (setq txt (getfiled "choose a file P,X,Y (*.txt)" "" "txt" 16))
(if (setq des (open txt "r"))
(progn
(while (setq lin (read-line des))
(setq lst (cons (mapcar '(lambda ( a b ) a) (LM:str->lst lin del) hdl) lst))
)
(setq des (close des))
(if lst
(if (setq ins (getpoint "\nSpecify point for table: "))
(LM:addtable
(vlax-get-property (vla-get-activedocument (vlax-get-acad-object))
(if (= 1 (getvar 'cvport))
'paperspace
'modelspace
)
)
(trans ins 1 0) ttl (cons hdl (reverse lst)) nil
)
)
(princ "\nNo valid data found in selected file.")
)
)
(princ "\nUnable to open selected file for reading.")
)
)
(princ)
)
;;---------------------------=={ Add Table }==--------------------------;;
;; ;;
;; Creates an AutoCAD Table Object at the specified point, populated ;;
;; with the given data and optional title. ;;
;;----------------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;;
;;----------------------------------------------------------------------;;
;; Arguments: ;;
;; spc - VLA Block object ;;
;; ins - WCS Insertion point for table ;;
;; ttl - [Optional] Table title ;;
;; lst - Matrix list of data to populate the table ;;
;; eqc - If T, columns are of equal width ;;
;;----------------------------------------------------------------------;;
;; Returns: VLA Table Object ;;
;;----------------------------------------------------------------------;;
(defun LM:AddTable ( spc ins ttl lst eqc / dif hgt i j obj stn sty wid )
(setq sty
(vlax-ename->vla-object
(cdr
(assoc -1
(dictsearch
(cdr
(assoc -1
(dictsearch (namedobjdict) "acad_tablestyle")
)
)
(getvar 'ctablestyle)
)
)
)
)
)
(setq hgt (vla-gettextheight sty acdatarow))
(if (LM:Annotative-p (setq stn (vla-gettextstyle sty acdatarow)))
(setq hgt (/ hgt (getvar 'cannoscalevalue)))
)
(setq wid
(mapcar
(function
(lambda ( col )
(apply 'max
(mapcar
(function
(lambda ( str )
( (lambda ( box ) (if box (+ (* 2.5 hgt) (- (caadr box) (caar box))) 0.0))
(textbox
(list
(cons 01 str)
(cons 40 hgt)
(cons 07 stn)
)
)
)
)
)
col
)
)
)
)
(apply 'mapcar (cons 'list lst))
)
)
(if
(and ttl
(< 0.0
(setq dif
(/
(-
( (lambda ( box ) (if box (+ (* 2.5 hgt) (- (caadr box) (caar box))) 0.0))
(textbox
(list
(cons 01 ttl)
(cons 40 hgt)
(cons 07 stn)
)
)
)
(apply '+ wid)
)
(length wid)
)
)
)
)
(setq wid (mapcar '(lambda ( x ) (+ x dif)) wid))
)
(setq obj
(vla-addtable spc
(vlax-3D-point ins)
(1+ (length lst))
(length (car lst))
(* 2.0 hgt)
(if eqc
(apply 'max wid)
(/ (apply '+ wid) (float (length (car lst))))
)
)
)
(vla-put-regeneratetablesuppressed obj :vlax-true)
(vla-put-stylename obj (getvar 'ctablestyle))
(setq i -1)
(if (null eqc)
(foreach col wid
(vla-setcolumnwidth obj (setq i (1+ i)) col)
)
)
(if ttl
(progn
(vla-settext obj 0 0 ttl)
(setq i 1)
)
(progn
(vla-deleterows obj 0 1)
(setq i 0)
)
)
(foreach row lst
(setq j 0)
(foreach val row
(vla-settext obj i j val)
(setq j (1+ j))
)
(setq i (1+ i))
)
(vla-put-regeneratetablesuppressed obj :vlax-false)
obj
)
;; Returns T if the given Textstyle is annotative
(defun LM:annotative-p ( sty )
(and (setq sty (tblobjname "style" sty))
(setq sty (cadr (assoc -3 (entget sty '("AcadAnnotative")))))
(= 1 (cdr (assoc 1070 (reverse sty))))
)
)
;; String to List
;; Separates a string using a given delimiter
;; str - [str] string to process
;; del - [str] delimiter by which to separate the string
(defun LM:str->lst ( str del / pos )
(if (setq pos (vl-string-search del str))
(cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
(list str)
)
)
;;----------------------------------------------------------------------;;
(vl-load-com)
(princ
(strcat
"\n:: Text2Table.lsp | Version 1.1 | \\U+00A9 Lee Mac "
(menucmd "m=$(edtime,0,yyyy)")
"\n:: Type \"txt2tab\" to Invoke ::"
)
)
(princ)
;;----------------------------------------------------------------------;;
;; End of File ;;
;;----------------------------------------------------------------------;;
thanks