Author Topic: Overview of "ACAD" Xdata scope?  (Read 2837 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Overview of "ACAD" Xdata scope?
« on: February 20, 2014, 05:29:15 AM »
The "ACAD" Xdata appid is used for multiple purposes ("MVIEW", "DSTYLE" etc.?). Is there an overview somewhere? Can a single entity have "ACAD" Xdata for more than one purpose?

Example:
If I want to remove dim overrides can I just remove all "ACAD" Xdata or should I worry about data not related to the dimstyle?

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Overview of "ACAD" Xdata scope?
« Reply #1 on: February 22, 2014, 05:23:50 AM »
If I want to remove dim overrides can I just remove all "ACAD" Xdata or should I worry about data not related to the dimstyle?
If you're worried that the dimension might have some other ACAD XData attached to it, then the dim overrides are placed within a DSTYLE subgroup of ACAD.

It starts with a (1000 . "DSTYLE") item and continues to the next (1002 . "}"). See CAB's example here: http://www.theswamp.org/index.php?topic=3313.msg40725#msg40725

Here's an example to clear only the DSTYLE portion from the ACAD XData group:
Code - Auto/Visual Lisp: [Select]
  1. (defun clear-xdata-dstyle  (entity / acad-xdata started)
  2.   (if (setq acad-xdata (assoc "ACAD" (cdr (assoc -3 (entget entity '("ACAD"))))))
  3.     (progn (setq acad-xdata
  4.                   (vl-remove-if
  5.                     '(lambda (item)
  6.                        (cond
  7.                          (started
  8.                           (or t (setq started (not (equal item '(1002 . "}"))))))
  9.                          ((equal item '(1000 . "DSTYLE")) (setq started t))))
  10.                     acad-xdata))
  11.            (entmod (list (cons -1 entity) (cons -3 (list acad-xdata)))))))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Overview of "ACAD" Xdata scope?
« Reply #2 on: February 22, 2014, 11:50:48 AM »
Code - Auto/Visual Lisp: [Select]
  1. (or t (setq started (not (equal item '(1002 . "}"))))))

I don't think the second expression in this OR statement will ever be evaluated, since OR will cease evaluation when a given expression returns a non-nil value...

FWIW, I would write it as:
Code - Auto/Visual Lisp: [Select]
  1. (defun clear-dim-xd ( ent / lst tmp )
  2.     (if
  3.         (and
  4.             (setq lst (assoc "ACAD" (cdr (assoc -3 (entget ent '("ACAD"))))))
  5.             (setq tmp (member '(1000 . "DSTYLE") lst))
  6.         )
  7.         (entmod
  8.             (list (cons -1 ent)
  9.                 (cons -3
  10.                     (list
  11.                         (append
  12.                             (reverse (cdr (member '(1000 . "DSTYLE") (reverse lst))))
  13.                             (cdr (member '(1002 . "}") tmp))
  14.                         )
  15.                     )
  16.                 )
  17.             )
  18.         )
  19.     )
  20. )

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Overview of "ACAD" Xdata scope?
« Reply #3 on: February 22, 2014, 02:08:49 PM »
I don't think the second expression in this OR statement will ever be evaluated, since OR will cease evaluation when a given expression returns a non-nil value...
Ah! Sorry yes ... the t should be the last value evaluated on that line. Thanks for spotting it Lee.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Overview of "ACAD" Xdata scope?
« Reply #4 on: February 24, 2014, 05:05:25 AM »
Thank you for your answer irneb. You are right to point to the use of braces (group code 1002) inside "ACAD" Xdata. Even if currently an entity will only have one 'type' of "ACAD" Xdata attached, the braces suggest that this may change in the future.

Regarding the provided code samples:
Looking for the first occurrence of (1002 . "}") after (1000 . "DSTYLE") works for the current version of "DSTYLE" data. But Xdata braces can be nested. So checking for pairs would be safer.

I am still interested in an overview of "ACAD" Xdata though...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Overview of "ACAD" Xdata scope?
« Reply #5 on: February 24, 2014, 07:53:30 AM »
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.


Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Overview of "ACAD" Xdata scope?
« Reply #7 on: February 24, 2014, 06:13:13 PM »
But Xdata braces can be nested. So checking for pairs would be safer.

Good point Roy.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Overview of "ACAD" Xdata scope?
« Reply #8 on: February 25, 2014, 04:19:13 AM »
@ CAB: Thanks for the links. But I am not looking for general information on Xdata or dictionaries. My example is only there to illustrate why having an "ACAD" appid overview can be relevant.