Jump to content

Delete data by xdata information : error


sidharth

Recommended Posts

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

Link to comment
Share on other sites

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)
         )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...