sidharth Posted December 15, 2009 Share Posted December 15, 2009 Hi, My drawing has differnet type of entities (Polyline (closed), circle, line, point) and has xdata attached to it. xdata INDEX a unique value. I am trying a code to delete a entity according to xdata index (defun c:delobj () (setq selobj (entsel "Select the object to Delete:")) (setq ndx (cdr(cadr (cadr (assoc -3 (entget (car selobj) '("Index"))))))) (setq a (ssget "X" (list (list -3 (list "Index" (cons 1000 ndx)))))) (setq b (ssname a 0)) (entdel b) ) I am able to delete Polylines (closed) and circles only but line and point a showing an error. Thanks in advance Sidharth kamasani Quote Link to comment Share on other sites More sharing options...
SteveK Posted December 15, 2009 Share Posted December 15, 2009 I think this thread will help you. Basically you can't do it that way. Here's that thread accommodated for you: (defun c:delents (/ EN I SS VAL) ;; Courtesy of MP, http://www.theswamp.org/index.php?topic=7229.msg89412#msg89412 (defun RemoveFromPicksetIf ( ss func / I ENAME) ;; The supplied func must take one ;; argument, an ename. What it does ;; we don't care, but if it returns ;; a non nil result remove the entity ;; from the pickset (if (eq 'pickset (type ss)) (repeat (setq i (sslength ss)) (if (func (setq ename (ssname ss (setq i (1- i)) ) ) ) (ssdel ename ss) ) ) ) ss ) (AND (setq en (entsel)) (setq val (cdr (assoc 1000 (cdr (assoc "INDEX" (cdr (assoc -3 (entget (car en) (list "*"))))))))) (setq ss (RemoveFromPicksetIf (ssget "X" '((-3 ("INDEX")))) (lambda ( ename / xdata ) (or (null (setq xdata (assoc -3 (entget ename '("INDEX") ) ) ) ) (null (member (cons 1000 val) (cdadr xdata) )))))) (setq i -1) (while (setq en (ssname ss (setq i (1+ i)))) (entdel en) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted December 15, 2009 Share Posted December 15, 2009 Hi,(setq a (ssget "X" (list (list -3 (list "Index" (cons 1000 ndx)))))) I may be wrong, but I don't think that you can use xdata (-3) in a ssget "X" filter. ( from somewhere in the back of my under used part of my memory ) -David Quote Link to comment Share on other sites More sharing options...
sidharth Posted December 17, 2009 Author Share Posted December 17, 2009 Thanks all for your valueable soltions warm regds Sidharth kamasani Quote Link to comment Share on other sites More sharing options...
SteveK Posted December 17, 2009 Share Posted December 17, 2009 Hope you get somethin working. Quote Link to comment Share on other sites More sharing options...
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.