C++
ACDBCORE2D_PORT AcRxObject* clone() const;
Description
Function usage:
This function creates a clone of the object and returns a pointer to the clone. If the function is not successful in creating the clone, then NULL is returned.
The intended behavior of this method is to do a shallow copy. The default implementation and the implementation in all of the AutoCAD built-in classes follows this design.
The shallow copy operation means that only the current object is cloned, particularly for AcDbObject. For complex objects, the deepClone mechanism should be used instead.
Function implementation in derived classes:
Return pointer to a copy of messaged object, if it is copyable. This should be a pure virtual function, it is implemented to create an instance of its own class, using AcRxClass::create(). If the result is non-null, then invoke copyFrom() on it.
The implementation is up to the developer, but the clone operation is generally applied only to the current object. This is particularly true for AcDbObject and classes derived from it.
Default implementation:
A new object of the same class as *this is created via the class's AcRxClass object's create() method (which uses the object's make method defined in the AcRx macros. The default for this is simply a new), then the new object's copyFrom() method is invoked passing in a pointer to this object as the object to copy from.