Jump to content

Recommended Posts

Posted

I have a function to delete Xdata as follows:

(defun DeleteXData (ename app / edata newdata)
  (setq edata (entget ename '("*")))  
  (setq newdata
    (vl-remove-if
      (function
        (lambda (x)
          (and (eq (car x) -3) ; là XDATA
               (eq (car (car (cdr x))) app)))  
      )
      edata
    )
  )
  (entmod newdata)  
  (entupd ename)   
)

Pline Xdata :  ((-1 . <Entity name: 2ae44387aa0>) (0 . "LWPOLYLINE") (330 . <Entity name: 2ae1c3961f0>) (5 . "ECEA") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbPolyline") (90 . 4) (70 . 0) (43 . 0.0) (38 . 0.000508626) (39 . 0.0) (10 588879.0 1.53624e+06) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 588886.0 1.53623e+06) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 588869.0 1.53616e+06) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 588851.0 1.53617e+06) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0) (-3 ("ED0ATenTD" (1000 . "(\"ED0A\")")) ("F778TenTD" (1000 . "(\"F778\")")) ("FDAETenTD" (1000 . "(\"FDAE\")")) ))

Can I ask why the function is not working ? 

Posted

Hello
Have you ever used this code and did it work for you?

  • Like 1
Posted

Maybe something like this will help you:

 

....................
(setq ename (car (entsel))
      edata (entget ename '("*"))
      data (cdr (assoc -3 edata))
      )
(foreach memb data
  (setq nlst (cons -3 (list (cons (car memb) nil))))
  (setq ndata (subst nlst (assoc -3 edata) edata))
  (entmod ndata)
  )
....................

 

  • Like 2
Posted
13 minutes ago, GLAVCVS said:

Hello
Have you ever used this code and did it work for you?

I have created save and read xdata but am struggling to find a way to delete it, the code is not executed yet!

Posted

After the XDATA deleted, you can check with command XDLIST, select that entity and you will get like this:

"No Xdata associated with Application Name(s).
Object has 16383 bytes of Xdata space available."

 

  • Like 1
Posted
13 minutes ago, Saxlle said:

Maybe something like this will help you:

 

....................
(setq ename (car (entsel))
      edata (entget ename '("*"))
      data (cdr (assoc -3 edata))
      )
(foreach memb data
  (setq nlst (cons -3 (list (cons (car memb) nil))))
  (setq ndata (subst nlst (assoc -3 edata) edata))
  (entmod ndata)
  )
....................

 

Thanks a lot Saxlle! The code works great. I don’t fully understand how it works yet (it will take some time) but it’s very useful!

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