Hi,
I am creating lisp routine and the work is to selected Mtext or text and the corresponding content is to be added as Xdata to the selected entity.
(defun C:addxdata()
(setq a(entget(car(entsel"\nSelect Text: "))))
(setq Xdata1 (cdr (assoc 1 a))) (princ Xdata1)
(setq b(entget(car(entsel"\nSelect Text: "))))
(setq Xdata2 (cdr (assoc 1 b))) (princ Xdata2)
(regapp "Test_Xdata" )
(setq oldlist (entget (car (entsel))))
(setq thedata '((-3 ("Test_Xdata" (1000 . Xdata1) (1000 . Xdata2 ))))) )
Then I used list Xdata option available under Express tool Tab (Auto Cad 2014).
I didn't find any Xdata Attached with it.
After Adding the Xdata, I wanna export to Excel.
For the Excel Conversion, Lisp is working good.
I guess the Problem is in the following line,
(setq thedata '((-3 ("Test_Xdata" (1000 . Xdata1) (1000 . Xdata2 )))))
Though the value stored in variable it is not working properly.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Try
(defun C:addxdata ( / a adata b bdata c newlist oldlist thedata Xdata1 Xdata2) (if (and (setq a (car (entsel "\nSelect Text: "))) (setq adata (entget a)) (wcmatch (cdr (assoc 0 adata)) "TEXT,MTEXT") (setq Xdata1 (cdr (assoc 1 adata))) (princ Xdata1) (setq b (car (entsel "\nSelect Text: "))) (setq bdata (entget b)) (wcmatch (cdr (assoc 0 bdata)) "TEXT,MTEXT") (setq Xdata2 (cdr (assoc 1 bdata))) (princ Xdata2) (setq c (car (entsel "\nSelect object to attach xdata..."))) (setq oldlist (entget c)) ) (progn (regapp "Test_Xdata") (setq thedata (list (list -3 (list "Test_Xdata" (cons 1000 Xdata1) (cons 1000 Xdata2) ) ) ) ) (setq newlist (append oldlist thedata)) (entmod newlist) ) ) (princ) )
String
1000. Strings in extended data can be up to 255 bytes long (with the 256th byte reserved for the null character).
Henrique