OHandles
The simplest way to reference an object in is to use the memory address of the data structure that describes that object. To prevent the application from accessing the content of the data structure for the object directly, the declaration of the structure is not provided. For example, the object handle ProSurface is defined as follows:
typedef struct geom* ProSurface;
The structure struct geom is used to describe a surface in , but the declaration of the structure is not included in . This type of handle is called an opaque handle or opaque pointer for this reason.
Opaque handles have the advantage of simplicity and efficiency—they can be directly dereferenced inside the function without any searching. They can also reference items that are transient and not in the database at all, such as the surfaces and edges that result from an interference volume calculation.
Other examples of objects that are given OHandles are as follows:
typedef void* ProMdl;
typedef struct curve_header* ProEdge;
typedef struct sld_part* ProSolid;
typedef struct entity* ProPoint;
typedef struct entity* ProAxis;
typedef struct entity* ProCsys;
typedef struct entity* ProCurve;
Because opaque handles are just memory pointers, they suffer the disadvantage of all pointers in that they are volatile—they become invalid if the database object they refer to moves to a different memory location. For example, a ProSurface handle (a pointer to a surface) may become invalid after regeneration of the owning part (because its memory has been reallocated).
However, most of the structures referenced by opaque handles contain an integer identifier that is unique for items of that type within the owning model. This identifier retains its value through the whole life of that item, even between sessions of . provides functions such as
ProSurfaceIdGet() and
ProAxisIdGet() that enable your application to use these identifiers as a persistent way to reference objects. These integer identifiers are also used in DHandles, described in the following section.
In the case of models, it is the name and type that are persistent. The functions
ProMdlMdlnameGet() and
ProMdlTypeGet() provide the name and type of a model, given its opaque handle.
Parent topic