Author Topic: Xdata Remover  (Read 7783 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7264
Xdata Remover
« on: November 09, 2004, 06:01:02 PM »
Does anyone have a lisp that will strip (erase) all xdata out of a drawing?

Thanks,

Ron

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7264
Xdata Remover
« Reply #1 on: November 09, 2004, 06:16:41 PM »
Found this one:

Code: [Select]
(defun C:DeleteAllXdata ( / curass countr)
 (setq curass (ssget "X" '((-3 ("*"))))
       countr 0
 )
 (if curass
  (repeat (sslength curass)
   (DelXdata (ssname curass countr) '("*"))
   (setq countr (1+ countr))
  )
 )
 (princ)
)
(defun DelXdata (ent app / entlst tmplst)
 (setq entlst (entget ent app))
 (foreach memb (cdr (assoc -3 entlst))
  (setq tmplst (cons -3 (list (cons (car memb) nil)))
        entlst (subst tmplst (assoc -3 entlst) entlst)
        entlst (entmod entlst)
  )
 )
)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

hyposmurf

  • Guest
Xdata Remover
« Reply #2 on: November 10, 2004, 03:26:24 PM »
What exactly is XDATA?Extended data?Attributes info?

ronjonp

  • Needs a day job
  • Posts: 7264
Xdata Remover
« Reply #3 on: November 10, 2004, 03:33:03 PM »
It is extended data written to an object.......from the help file:
 



Code: [Select]
Extended data (xdata) is created by AutoLISP or ObjectARX applications. If an entity contains extended data, it follows the entity's normal definition data. The group codes 1000 through 1071 describe extended data. The following is an example of an entity containing extended data in DXF format.

Normal entity definition data:

  0
INSERT
  5
F11
100
AcDbEntity
  8
TOP
100
AcDbBlockReference
 2
BLOCK_A
 10
0.0
 20
0.0
 30
0.0
Extended entity definition data:

1001
AME_SOL
1002
{
1070
 0
1071
 1.95059E+06
1070
 519
1010
2.54717
1020
2.122642
1030
2.049201
1005
ECD
1005
EE9
1005
0
1040
0.0
1040
1.0
1000
MILD_STEEL
The group code 1001 indicates the beginning of extended data. In contrast to normal entity data, with extended data the same group code can appear multiple times, and order is important.

Extended data is grouped by registered application name. Each registered application group begins with a 1001 group code, with the application name as the string value. Registered application names correspond to APPID symbol table entries.

An application can use as many APPID names as needed. APPID names are permanent, although they can be purged if they aren't currently used in the drawing. Each APPID name can have no more than one data group attached to each entity. Within an application group, the sequence of extended data groups and their meaning is defined by the application.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

David Bethel

  • Swamp Rat
  • Posts: 650
Xdata Remover
« Reply #4 on: November 10, 2004, 03:41:19 PM »
Ron,

That takes care of the main entity extended data.  It skips all block table entities and sequential insert attribs, nested block entities and / or heavy polyline vertices.

It will get rid of all of your paperspace viewport layer data as well.  A bit dangerous but I do it on a regular basis for cleaning up drawings sent to me by others.  -David
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Xdata Remover
« Reply #5 on: November 10, 2004, 05:06:24 PM »
You could modify this.
Code: [Select]
;; ! ****************************************************************************
;; ! XD_remxd
;; ! ****************************************************************************
;; ! Function : removes extended entity data from selection
;; ! Arguments:
;; !            'ss'      - Selection set to process
;; !            'AppName' - Application Name to remove Xdata (cannot be * or
;; !                        wildcards)
;; !            'Verbose' - If T, a message is displayed while deleting
;; ! Action   : Checks for extended entity data and removes them
;; ! Returns  : The selection set and number of objects whose Xdata was removed,
;; !            as well as the number of objects ignored.
;; ! Updated  : March 19, 1999
;; ! Copyright: (C) 2000, Four Dimension Technologies, Singapore
;; ! Contact  : rakesh.rao@4d-technologies.com for help/support/info

(defun xd_remxd (ss appname verbose / xd ssl cnt ename tmp numproc numnotproc remss)

  (setq numproc 0
        numnotproc 0
        remss (ssadd)
  )

  (if (= (type ss) 'ename)
    (progn
      (setq tmp (ssadd))
      (ssadd ss tmp)
      (setq ss tmp)
    )
  )

  (if ss
    (progn
      (setq
        cnt 0
        ssl (sslength ss)
        tmp (strcat " of " (itoa ssl))
      )
      (if verbose
        (princ "\n")
      )
      (repeat ssl
        (setq
          ename (ssname ss cnt)
          xd    (assoc -3 (entget ename (list appname)))
          cnt   (1+ cnt)
        )
        (if xd
          (progn
            (entmod (list (cons -1 ename) (list -3 (list appname))))
            (setq numproc (1+ numproc))
            (ssadd ename remss)
          )
          (setq numnotproc (1+ numnotproc))
        )

        (if verbose
          (princ
            (strcat "\rRemoving extended entity data belonging to application "
                    appname
                    "..."
                    (itoa cnt)
                    tmp
            )
          )
        )
      )
    )
  )
  (list (if (> (sslength remss) 0)
          remss
          nil
        )
        numproc
        numnotproc
  )
)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.