Author Topic: how to delete xdata?  (Read 22130 times)

0 Members and 2 Guests are viewing this topic.

TonyT

  • Guest
Re: how to delete xdata?
« Reply #15 on: June 23, 2007, 09:11:02 AM »
Hi Mike. Everyone here seems to be confused about what I
talked about in my original post.

The issue I raised about Keith's approach has nothing to do
with whether deleting xdata is or isn't appropriate.

It has to do with his method of doing it, which doesn't do
what some may think it does.

To demonstrate, draw a circle with the current color set to
'BYLAYER', and the current layer's color set to 7 (the default).

Next set the current color in the editor to red, or something
other than BYLAYER, and then do this:

   (setq circle (entget (entlast)))

Move the circle just drawn a bit so the 'copy'  is not coincident
with it, and then do this:
 
   (entmake circle)

What color is the original circle, and what
color is the 'copy' of the circle created with
(entmake) ?

That's what I meant by "entmake and entget do not
have compatible argument/result lists". :-)

I have mixed feelings about removing xdata, since there are equally valid reasons for protecting it as well as removing it. To wit, many of the programs I've written rely on the presence of xdata, be it placed and managed by my applications or third parties like Autoplant.

On the other hand, I've had clients specifically have me write lobotomy type applications -- to purge all xdata, dictionaries et al in order to sanitize 'intelligent' drawings for other purposes.

In either case I'd be very careful when shaking off xdata by deleting and recreating entities unless I fully appreciated all the ramifications of doing so, especially all the different means by which entity / object relationships exist, and subsequently can be broken.

Does Keith? In that I've no doubt.

Should the general viewing audience be warned? ABSOLUTELY.

So, if one knows what they're doing, this non destructive (in terms of retaining the original entity) may be of interest:

Code: [Select]
(defun _RemoveXdata ( ename appidlist / xdata )

    ;;========================================================
    ;;
    ;;  Caller's responsibility to ensure valid entity
    ;;  passed to function (including editable state)
    ;;
    ;;--------------------------------------------------------
    ;;
    ;;  Remove all xdata:
    ;;
    ;;      (_RemoveXdata ename '("*"))
    ;;
    ;;  Remove specific xdata, form 1:
    ;;
    ;;      (_RemoveXdata ename '("appid1,appid2"))
    ;;
    ;;  Remove specific xdata, form 2:
    ;;
    ;;      (_RemoveXdata ename '("appid1" "appid2"))
    ;;
    ;;  Remove wildcarded xdata:
    ;;
    ;;      (_RemoveXdata ename '("appid*"))
    ;;
    ;;========================================================

    (if (setq xdata (cdr (assoc -3 (entget ename appidlist))))
        (entmod
            (append
                (entget ename)
                (list
                    (cons -3
                        (mapcar
                           '(lambda (x) (list (car x)))
                            xdata
                        )   
                    )
                )   
            )
        )
    )
)

TonyT

  • Guest
Re: how to delete xdata?
« Reply #16 on: June 23, 2007, 09:15:55 AM »
Well, better late than never, eh Mike ?

Gentlemen, before this turns into a bit throwing contest I encourage you to make the attempts to speak to each other cordially and respectfully. Thank you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: how to delete xdata?
« Reply #17 on: June 23, 2007, 09:25:11 AM »
Hi Tony.

Just because some folks didn't comment on it doesn't mean that "everyone is confused about it".

But to be clear, without explicit properties included in the dxf group codes, entmake will adopt what is current, like cecolor et al, which can yield unexpected results.

Michael.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: how to delete xdata?
« Reply #18 on: June 23, 2007, 09:26:25 AM »
Well, better late than never, eh Mike ?

Well I do have a life and commitments beyond this board.

:D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

TonyT

  • Guest
Re: how to delete xdata?
« Reply #19 on: June 23, 2007, 09:30:03 AM »
So, is this about my incorrect use of the word 'everyone', or
the incorrect and improper use of (entget) and (entmake) to
remove xdata, but do nothing else ?

Yes, Mike that's right, entmake adopts the current editor
properties, not the properties of the object whose entity
data was returned by entget, but that isn't removing xdata.
That is removing xdata and possibly changing properties of
the object.

And I won't even get into how it screws up field references,
draworder, and various other things that involve references
to other objects using handles.

Hi Tony.

Just because some folks didn't comment on it doesn't mean that "everyone is confused about it".

But to be clear, without explicit properties included in the dxf group codes, entmake will adopt what is current, like cecolor et al, which can yield unexpected results.

Michael.

:)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: how to delete xdata?
« Reply #20 on: June 23, 2007, 09:34:07 AM »
So, is this about my incorrect use of the word 'everyone', or ...

I was addressing the assumption / assertion that everyone is confused.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

TonyT

  • Guest
Re: how to delete xdata?
« Reply #21 on: June 23, 2007, 09:41:22 AM »
Mike - Post warnings in reponse to posts that justify
the warnings, not in response to the response to it.

And I realize that you don't live in a bubble, but you
posted in the thread at the point when the warning
should have been posted, but wasn't.

Well, better late than never, eh Mike ?

Well I do have a life and commitments beyond this board.

:D

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: how to delete xdata?
« Reply #22 on: June 23, 2007, 09:58:05 AM »
... you posted in the thread at the point when the warning  should have been posted, but wasn't.

Acknowledge.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: how to delete xdata?
« Reply #23 on: June 23, 2007, 08:24:50 PM »
...........
What you fail to realize is that once "your" drawing is in my hands .. unless I am working for you, the presence of the data is of no consequence.
.............

Keith,

I probably won't care what you (or anyone) do with 'my' drawings { If they are issued for info only }

I do care about code you (or anyone) deliver to me which is supposedly designed to have a specific functionality but has the side effect of destroying my data.


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: how to delete xdata?
« Reply #24 on: June 24, 2007, 12:48:49 PM »
I do care about code you (or anyone) deliver to me which is supposedly designed to have a specific functionality but has the side effect of destroying my data.

But wasn't that the desired effect in the beginning? To destroy the data?

I think the tone of the topic has changed a bit from what it was meant to be to something entirely different.

Tony, just so we are perfectly clear .. the code above was not meant to be complete ... but rather a snippet of how something could be done ... that being, if you collect the entity list of an object, sans the xdata, then re-write that entity list directly without having to change it, the entity would be re-written and there would be no xdata attached.

You are correct that the new object could take on the properties set current, but only if they have not already been hard coded to something else. i.e. if a line has been hard coded to be red and you create that line using entmake, it will indeed be red, even if you have the current color property to something else.

With regards to your widget which requires an object enabler, I think perhaps you are being a little bit disengenuous, since without your program that created that object, it cannot be edited, copied or created, because AutoCAD does not know how to handle it. Therefore one could not possibly edit any widget for which they do not have the programming to do so with. Therefore in my example given above, I could not have created the a new widget using your custom object as a base. When I was refering to a widget, I was refering to any collection of native AutoCAD objects (i.e. lines creating a door or window) that can be edited to form another widget (i.e. a bolt, shelf or appliance). Perhaps the terms I chose were not clear enough to elicit the thought process I had hoped.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: how to delete xdata?
« Reply #25 on: June 24, 2007, 05:04:27 PM »
Keith

Choose any entity.
Then add an XRecord for my data.
Then reference the entity from a field object.

Then put your Xdata on the entity.

added: then add an object reactor, just for the fun of it.

Now, delete your xdata, your way, and let us know what happens.


I do care about code you (or anyone) deliver to me which is supposedly designed to have a specific functionality but has the side effect of destroying my data.

But wasn't that the desired effect in the beginning? To destroy the data?

............
« Last Edit: June 24, 2007, 05:29:07 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: how to delete xdata?
« Reply #26 on: June 25, 2007, 11:11:00 AM »
Wow, I'm surprised how hot this topic got.

I have to say I can see Keith's side of wanting to purge all extraneous data, and if he's using the file for his own purpose, it seems like a valid thing to do.

I would say that if a drawing that contains xdata is meant to go between agencies with said xdata preserved, then all parties involved should know that and protect the xdata appropriately. If someone runs Kieth's superpurge-deathtoallxdata.lsp on a drawing that they shouldn't have, then they are liable for it. There's nothing wrong with Kieth providing the tools for it. After all, lisp doesn't kill xdata, people do!

Maverick®

  • Seagull
  • Posts: 14778
Re: how to delete xdata?
« Reply #27 on: June 25, 2007, 11:27:42 AM »
hi:
    please tell me how to delete xdata?

  Considering this was the original post.....  Pretty scarce on details but it sounds like Keith provided what OP wanted.  The warning is nice though.

  Kinda like someone asking "How do I remove Windows from my computer"?   :-)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: how to delete xdata?
« Reply #28 on: June 25, 2007, 04:39:31 PM »

Chuck Gabriel posted the solution the OP was looking for, it seems.

In VBA (and probably .NET as well) the method is to overwrite the xdata for the desired regapp name with a list that consists of nothing but the regapp info.
..............
it's ok.
thanks.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Nathan Taylor

  • Guest
Re: how to delete xdata?
« Reply #29 on: June 25, 2007, 06:33:11 PM »
Yep. In the correct Language and only doing what was asked without side effects.

Chuck Gabriel posted the solution the OP was looking for, it seems.

In VBA (and probably .NET as well) the method is to overwrite the xdata for the desired regapp name with a list that consists of nothing but the regapp info.
..............
it's ok.
thanks.