Hi Everyone,
I'm looking about implementing copy & paste functionality on my custom entities.
Shoud I implement some interface?
Another problem could be the copy of associated extended dictionary..
I tried to copy an object with CTRL+c and CTRL+V and the pasted object is of the base class type.
Thank you for your help!
Hi,
Copy / Paste is implemented through deep cloning, I suggest you to have a look in ObjectARX documentation:
Object ARX developer's guide > Advanced topics > Deep cloning.
As a brief summary, there are three main types of cloning operations:
1. shallow clone (AcRxObject::clone)
2. deep clone (AcDbObject::deepClone / subDeepClone)
3. wblock clone ((AcDbObject::wblockClone / subWblockClone)
1. shallow clone performs a clone on the current object only
2. deep clone performs a more complex cloning operation, it clones the object and follows all soft references (pointers and ownsership(*)) is has , this type of cloning is used to clone objects in a single database
3. wblock clone performs yet another kind of cloning, it clones the object itself and follows all hard references (*). This kind of cloning is used to clone objects accross databases.
(*) hard and soft references are an important concept when talking about cloning in acad, I strongly suggest to understand these concepts perfectly (see doc).
To implement cloning correctly, you'll have to override:
- AcDbObject::dwgInFields
- AcDbObject::dwgFields
- AcDbObject::subDeepClone
- AcDbObject::subWblockClone
Note that default implementation of subDeepClone and subWblockClone is often enough to perform correct cloning on custom objects.
Ctrl+C / Ctrl+V involves both wblock clone and deep clone operations.
I hope this helps
loic
Perfect,
I'm reading this section on the documentation.
Then I don't have to override the acdbobject::clone function on my custom entities?
Thank you for your precious answer.
Have a good day!
Can't find what you're looking for? Ask the community or share your knowledge.