PDA

View Full Version : Deleting Xdata?



whdjr
2004-08-24, 07:28 PM
How do you delete xdata?

whdjr
2004-08-24, 08:26 PM
Thanks for all you guys help. I figured it out though. I just had to find out which entities had the xdata attached to them and then use entmake to make another entity using the same entity list without the xdata. Easy right? HaHa.



(defun dxf (gcode elist)
(cdr (assoc gcode elist))
)

(defun ent_list (sel cnt / ent lst)
(repeat cnt
(setq cnt (1- cnt)
ent (ssname sel cnt)
lst (cons ent lst)
)
)
lst
)

(defun c:delxdata (/ ss num elst xelst int)
(princ "\nSelect entities to delete Xdata: ")
(if (and (setq ss (ssget)
int 0
)
(setq num (sslength ss))
)
(mapcar '(lambda (x)
(setq elst (entget x)
xelst (entget x (list "CGSURVEY_FOR_AUTOCAD8003671157")); This string is your AppID
)
(if (dxf -3 xelst)
(and (entdel x)
(entmake elst)
(setq int (1+ int))
)
)
)
(ent_list ss num)
)
(princ "\nNothing selected! ")
)
(if (> int 0)
(princ
(strcat "\nDeleted Xdata from " (itoa int) " entities! ")
)
)
(princ)
)

Hope this helps someone else.

Jeff_M
2004-08-24, 08:55 PM
Thanks for all you guys help. I figured it out though. I just had to find out which entities had the xdata attached to them and then use entmake to make another entity using the same entity list without the xdata. Easy right? HaHa.


Hi Will,
Just a few things......You can place the appname into the (ssget) so only entites with that xdata will be selected. Then, instead of deleting and then entmaking, just entmod like so:

(setq appnamne "CGSURVEY_FOR_AUTOCAD8003671157")
(setq ss (ssget (LIST (LIST -3 (list appname)))))

(entmod (list (cons -1 ename) (list -3 (list appname)))))

calling entmod with the xdata list empty removes any previously attached xdata.

HTH,
Jeff