Copying and pasting XData between drawings

Copying and pasting XData between drawings

SRSDS
Advisor Advisor
879 Views
6 Replies
Message 1 of 7

Copying and pasting XData between drawings

SRSDS
Advisor
Advisor

Hi again,

 

How can know if entities are being manually copied and pasted between drawings.

A thought is to add a GUID to each entities Xdata and check if the value is in the named object dictionary. 

 

0 Likes
880 Views
6 Replies
Replies (6)
Message 2 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

good idea, but copying the drawing (with file-copy) is not prevented with this way.

Not as criticism, just as info to think of it!

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 3 of 7

SRSDS
Advisor
Advisor

ohh.. good point! 

I will read the filename also as a second measure. Filenames might be the same as well but both would be rare.

Or maybe the file creation date and time. 

Probably no need to write anything as data. I just need to read the identifiers during copy and paste to see if they don't match. 

Thanks again.

0 Likes
Message 4 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

not sure what your global direction is. For me and my way of work, the filename is used as variable as possible.

1) On one side I save with a drawing-name ending with 2-4 digits as version-number and from time to time I do a _SAVEAS and increase the number.

2) On the other side, I transfer the files between computers (e.g. to home-office), continue to work and then copy it back (will be an allowed copy?)

3) not to forget, what if you get a file back by restoring from a backup-system (also allowed filecopy, isn't it?)

 

...and I think that there are a lot more reasons to copy a file and it sould be also valid out of your sight.

 

I think (without something like a data-managementserver, where the files are not stored in a filessystem you can directly access) it will not be possible to handle a filecopy with data stored within the DWG-file, that on one side allows the above variations but limit some - from your point of view - "not allowed"mechanism of copying.

Within the dataserver you have document-id's that give you the possibility of using a unique-id that you cannot get from a filesystem. However, also handling that with the fileserver is a challange.

 

Maybe you could describe more of "for what reason" are you doing that, then there may come some better ideas than this one.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 7

SRSDS
Advisor
Advisor

I really just need to know if the objects being pasted into a drawing have been copied from the same drawing.

COPYBASE command is the only event I need to consider.

I’ll tell users that other methods like inserting a drawing as a block then exploding isn't supported.

Maybe the file creation date and time is a good unique identifier to monitor.

Dim FileCreationTime As String = File.GetCreationTime(db.Filename())

 


 

0 Likes
Message 6 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

I even don't know what type of copy is now allowed, sorry. Why do you have to watch only _COPYBASE, there is also _COPYCLIP and also I think that not creating the copy-buffer will be the problem but the _PASTE*-methods have to be watched (or is it also not allowed to create a copy of geometry into MS-Word for documentation?).

 

The file-creation-date will also fail with my above types (backup-restore/copy to home-office/version-numbering).

 

And if you write EEDs and NOD, how will you handle the situation of home-work? Will you ensure that the home-pc will also run your application every time AutoCAD starts (and with any AutoCAD-profile and ...)

 

Now, after reading that .... all I'm writing look so pessimistic. Please understand that just as ideas, not as "all is nonesens"!

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 7

SRSDS
Advisor
Advisor

Hi Alfred.

Sorry. First time I've done this and have no experience at all. 

I personally only use COPYBASE between drawings. I wasn't thinking about COPYCLIP or CUTCLIP but will now.

 

Filename including the path should solve the drawing identification problem I think (checking source dwg = destination dwg). Two open drawings will never the same filepath & filename.

0 Likes