Close

Relief for ODA Team in Ukraine

Learn more
ODA Mechanical SDK
Operating Modes

Overview

There are two ways that you can work with Mechanical SDK: "enabler" or "editor" mode. The method you use generally depends on whether you want to work with existing mechanical files and objects as-is or convert them to the current version.

Note: The ability to switch modes was added in release 20.8.

The default "enabler" mode allows to read and render a database with mechanical entities as-is, without validation checks or creating additional objects. No special actions are required to use this mode — just load the mechanical modules.

Note: Files of older versions can be rendered incorrectly in enabler mode because Mechanical SDK does not convert all objects to the current mechanical version (this applies primarily to different revisions of symbol standards).

The second mode is "editor", which provides full functionality for interacting with mechanical objects: creating, editing, removing, saving to different versions, and so on. If using this mode, all objects during file reading are converted to the latest (current) version of mechanical objects format. Missing objects from the basic set are also created for correct operation with the mechanical database. To use Mechanical SDK in this mode, you must create an OdDbDatabaseMech database object, not an OdDbDatabase object.

Example

In the following code example, the MyServices class (inherited from the OdDbHostAppService class through intermediaries) is used for specific operations with modules. OdDbHostAppService has a special databaseClass() method that is used for database creation. So to use Mechanical SDK in "editor" mode, just override the databaseClass() method, and that will return a static OdRxClass description for the new database.

class MyServices : public ExSystemServices, public ExHostAppServices
{
protected:
  ODRX_USING_HEAP_OPERATORS(ExSystemServices);
public:
  virtual OdRxClass* databaseClass() const
  {
    return OdDbDatabaseMech::desc();
  };

The next step is to create a service object, initialize it, and create a database.

// create MyServices object
OdStaticRxObject<MyServices> svcs;

// initialize the ODA Platform
odInitialize(&svcs);

// load Mechanical modules
LoadTeighaMechanicalModules(false);

// next code creates an OdDbDatabaseMech object that allow to use
// Mechanical SDK in "editor" mode
OdDbDatabasePtr pDb = svcs.createDatabase(true, OdDb::kMetric);
pDb-> ... // get access to the created database

See Also

Supported Versions of .dwg Files

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