Share

acdbOpenObject

C++

template <class T_OBJECT> inline Acad::ErrorStatus acdbOpenObject(
    T_OBJECT*& pObj, 
    AcDbObjectId id, 
    AcDb::OpenMode mode = AcDb::kForRead, 
    bool openErased = false
);

File

dbObject.h

Description

Opens any database resident-object without knowing whether or not the object is derived from AcDbEntity. The function is passed in an empty pointer, pObj. The object ID of the object to open is objId. The mode to open in is mode. openErased is a Boolean indicating whether or not to open the object if it's erased.

The mode argument may be one of the following:

AcDb::kForRead

AcDb::kForWrite

AcDb::kForNotify

If the open attempt is successful, then pObj will be set to the address of the object and Acad::eOk will be returned.

If openErased is false, then attempting to open an erased object will fail and this function will return Acad::eWasErased.

If attempting to open AcDb::kForRead and the object is already opened for read the maximum of 256 times, then the open attempt will fail and this function will return Acad::eAtMaxReaders.

If the object is currently open AcDb::kForNotify, then the open attempt will fail and this function will return Acad::eWasNotifying.

If the object is currently involved in an undo operation, then the open attempt will fail and this function will return Acad::eWasOpenForUndo.

If the object is currently open AcDb::kForWrite, then the open attempt will fail and this function will return Acad::eWasOpenForWrite.

If objId is AcDbObjectId::kNull, then the open attempt will fail and this function will return Acad::eNullObjectId.

Note This function is a template function with one template argument, T_OBECT, which determines the type of the object to be opened. It is available for all classes using the ACRX_DECLARE_MEMBERS macro either directly or indirectly through other macros. The ACRX_DECLARE_MEMBERS macro provides a cast() member function which restricts the type of pObj.

Ultimately, this function calls either acdbOpenAcDbObject() or acdbOpenAcDbEntity().

Parameters

Parameters Description
pObj Output pointer to the opened object
id Input object ID of the object to open
mode Input mode in which to open object
openErased Input Boolean indicating whether it's OK to open an erased object

Returns

Returns Acad::eOk if the object is opened successfully, otherwise an error code.

Previous File

dbmain.h

Was this information helpful?