Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Proxy Objects
Working with Proxy Objects

What is a proxy object?

A proxy object is a substitute object that holds subdata for custom objects that cannot be loaded because the custom object's parent application is also not loaded.

The proxy object is a wrapper around the custom object which provides access to the base class properties, such as color, layer, linetype, and lineweight. The proxy object also encapsulates all of a custom class's data members that can only be accessed if the parent application is loaded.

Proxies can be created for both custom entities and custom objects in the OdDbProxyEntity and OdDbProxyObject classes, which are each derived from OdDbEntity and OdDbObject.

Life cycle of a proxy object

While reading a drawing file with custom objects, if the parent application is not loaded yet, an attempt to load the application is made (see the DEMANDLOAD system variable). If the application is not available, custom objects can't be loaded and proxies are created.

While saving a drawing with proxy objects to a file, there are two possible cases:

  • If the type of input and output file is the same (both .dwg or .dxf), a translation operation between .dwg and .dxf is not required. In-memory proxies are saved back as the original custom object.
  • If the type of input and output file is not the same (.dwg in and .dxf out, or vice versa), the format cannot be translated because the translation function defined by the parent application is not available. In this case, proxy objects are written to the output file as proxies.

While a drawing file with proxy objects is loaded, there are two possible cases:

  • If the parent application is available, an attempt is made to convert loaded proxy objects into custom objects.
  • If the parent application can't be loaded, proxies loaded from the file remain as proxies in memory.

Rendering proxy entities

While rendering proxy entities, the custom entity's worldDraw() and viewportDraw() functions can't be used because the parent application is not available.

For rendering proxy entities, Drawings SDK uses the entity's graphics metafile. This metafile is generated using the custom entity's worldDraw() or saveAs() functions at the moment when the file with the custom entity is saved. So, metafile contents completely depends on implementation of these functions.

Display mode of proxy entities is defined by the value of the PROXYSHOW system variable.

Editing proxy entities

Proxies provide limited editing functionality.

Operations that are allowed when a custom entity is a proxy are defined in the parent application.

Basic operations of changing linetype and linetype scale, color, layer, and visibility can be performed for a proxy entity and will be written out as a part of the OdDbEntity data.

Transformation operations such as move, rotate, and scale cannot be applied to the custom object until the drawing file with the transformed proxy entity is opened by the parent application. When transformations are applied to a proxy entity, they transform a graphics metafile, and a copy of the transformation matrix is saved in a custom record in the proxy entity's extension dictionary. Multiple transformations update the transformation matrix. As a result, this matrix stores the cumulative transformation's data. When you open a drawing file, the parent application calls the entity's transformBy() function and passes it the transformation matrix data that applied to the custom object. The custom data storage record is removed from the extension dictionary.

Exploding proxy entities

Proxy entities can be exploded using Drawings SDK standard exploding functions and are exploded using the contents of the proxy entity's graphics metafile. For more details, see Exploding Entities.

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.