Close

Relief for ODA Team in Ukraine

Learn more
ODA BimRv SDK
Open and Close Database Objects

Before you can read or modify a database object by working with its methods and properties, you must explicitly open the object for reading it or writing to it. You should also release it when the operation is completed.

Opening Objects

Having a proper Object ID, you can open the object in a specific mode using the safeOpenObject() method:

OdBmObjectPtr OdBmObjectId::safeOpenObject(OdBm::OpenMode openMode = OdBm::kForRead, bool openErasedOne = false) const;

Also, you can open an object using the openObject() method:

OdBmObjectPtr openObject() const;

Both of these methods contain the following openObject() method in their implementations:

OdResult openObject(OdBmObjectPtr& pObj) const;

The difference is that safeOpenObject() throws error codes if there are any, while openObject() just ignores them.

You can open an object in one of three modes:

  • for reading
  • for reading and writing
  • for notifying

For example, to open a Level element by its ObjectID you can call the mentioned method:


OdBmLevelPtr pLevel = newLevelId.safeOpenObject();
  

After the object is opened, you can access its methods and properties by using the created smart pointer object:


pLevel->setElevation(10.0);
  

Closing Objects

All objects implement smart pointer technology that is based on the reference counting mechanism and allows managing object lifecycles including closing and deleting objects. The close operation is done automatically when the smart pointers holding references to these objects go out of scope.

See Also

General Interaction with ODA BimRv SDK Objects

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