Determine if entities are pasted from another drawing

Determine if entities are pasted from another drawing

SRSDS
Advisor Advisor
1,721 Views
5 Replies
Message 1 of 6

Determine if entities are pasted from another drawing

SRSDS
Advisor
Advisor

Can anyone suggest a way to determine if entities being pasted originate from another drawing?

 

 

 

 

 

 

 

 

 

0 Likes
Accepted solutions (2)
1,722 Views
5 Replies
Replies (5)
Message 2 of 6

ActivistInvestor
Mentor
Mentor

Do you mean if entities are being pasted after being copied from another drawing versus being pasted after being copied from the same drawing?

0 Likes
Message 3 of 6

SRSDS
Advisor
Advisor

Yes from another drawing.

I've tried assigning a GUID each drawing and on copy events I write the GUID to a text file.

On Paste events I check if the documents GUID matches the one in the file.

I’ve just discovered a problem with it where the user does a COPYBASE in the original drawing (writing the original drawings GUID) then a standard COPY in the new drawing (writing the current drawings GUID to the file).  Pasting from the clipboard then thinks it is from/to the same drawing.

0 Likes
Message 4 of 6

ActivistInvestor
Mentor
Mentor
Accepted solution

Not sure what you mean by "paste events".  Do you mean handling the Database's BeginInsert event?

 

The only way to accomplish what you want to do, is to handle the WBLOCK events (in the same way it is done in the WblockGroupHandler class that I posted here and in my repo), and add the FingerprintGUID of the source database to the destination database (it could be stored in the xdata of the BlockTable, or any other place for that matter).  Then you need to handle the BeginInsert event. When the event is raised, look at the filename of the From Database, and see if it starts with "A$C". If so, that means its a PASTE operation (verses the INSERT command).  You can then access the FingerprintGUID you stored in the WBLOCK, operation, and compare that to the destination database's FingerprintGUID, to see if the From database was produced by a WBLOCK in the destination database.

 

 

0 Likes
Message 5 of 6

Norman_Yuan
Mentor
Mentor
Accepted solution

@SRSDS 

Inspired by your question, I put together some code to determine which the copy source is originated, which may or may not be exactly what your are after:

 

https://drive-cad-with-code.blogspot.com/2025/01/determine-object-source-when-using.html#google_vign... 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 6 of 6

SRSDS
Advisor
Advisor

Thank you so both so much again!

I wasn't entirely sure how to implement ActivistInvestor's suggestion so, Norman, thank you so much for putting that together. There would have been a slim to no chance of me working it out myself.

Really appreciated!

 

0 Likes