Share

AcDbEntity::getTransformedCopy

C++

ACDBCORE2D_PORT ADESK_SEALED_VIRTUAL Acad::ErrorStatus getTransformedCopy(
    const AcGeMatrix3d& xform, 
    AcDbEntity*& pEnt
) const;

Description

Function usage

This function creates a clone of the entity, applies the xform transformation matrix to the clone, and then returns with pEnt pointing to the transformed clone.

Returns Acad::eOk if successful.

If xform is a non-uniform scaling matrix or non-orthogonal then Acad::eCannotScaleNonUniformly or Acad::eNotImplemented is returned.

Warning

For AutoCAD built-in complex entities such as polylines, this function produces a shallow clone of the header entity only, which also owns the original set of "owned" entities (such as vertices for a polyline) which are then transformed by the xform matrix. This results in a corrupt drawing (two header entities owning the same set of "owned" entities) as well as transforming the original set of "owned" entities instead of a copied set.

Function implementation in derived classes

The default AcDbEntity implementation of this function should be adequate for most derived entity types. However, derived entity classes that wish to support non-uniform scaling or non-orthogonal transformations will need to override this method with their own implementation.

This function must create a copy of the entity (using memory that has been dynamically allocated via the C++ new operator), apply the transformation matrix xform to the copy and then return with pEnt pointing to the transformed copy.

Determining what constitutes a valid transformation matrix and whether to do a shallow clone (that is, the entity's clone() method), a deepclone (if the entity owns other objects), or no clone at all (that is, make this function a no-op), is up to the implementer.

Return values for this function are also up to the implementer, but to be consistent with other existing classes the following is recommended:

  • If the function succeeds, it should return Acad::eOk.
  • If the function is to be a no-op, it should return Acad::eNotImplemented
  • If non-uniform scaling is not to be supported and a non-uniform scaling matrix is passed in, then either Acad::eCannotScaleNonUniformly or Acad::eNotImplemented should be returned.

Default implementation

If the entity is uniformly scaled and orthogonal, AcDbEntity::getTransformedCopy will call the entity's clone() method to create a clone of the entity, then call AcDbEntity::transformBy() on the clone, and then return with pEnt set to point to the transformed clone. If xform is a non-uniformly scaled or a non-orthogonal matrix, then this function will return Acad::eNotImplemented.

Parameters

Parameters Description
xform Input matrix by which to transform the copy of the entity
pEnt Input reference to an "empty" pointer; output pointing to the transformed copy of the entity

Links

AcDbEntity

Was this information helpful?