DATAKIT SDK  V2026.3
Starting with Dtk_API

Main workflow

Datakit API allows you to get data from CAD files, all covered by the same implementation.

Dtk_API is a singleton. That means only one session can be running at a time.

General process follow these steps :

Session Start

You have to enable the readers you want to use calling static method Enable().

This will trigger the need to link against corresponding libraries (please see Datakit Libraries and usage or individual reader pages)

Start the API by calling Dtk_API::StartAPI()

//First You have to Enable the readers you want to use
//...
//...
//Then You have to Start DATAKIT API
Dtk_ErrorStatus errorStatus = dtkNoError;
Dtk_API * MyAPI = Dtk_API::StartAPI(TemporaryWorkingDirectory, errorStatus);

Document Context

When API is started you can use Dtk_API::OpenDocument() method to read a file. This method :

  • recognizes the input CAD file format
  • calls the corresponding reader
  • populates a global assembly tree (please see How to use Assembly Tree for details)

Assembly and Constructions Trees

From assembly tree root, you can browse components :

From this construction tree, you can browse tree nodes :

Session End

In order to properly free memory and re-initialize reader context :

All classes except Dtk_API are handled via Smart Pointers.
They are deleted and freed automatically when they are out of scope.
See How to use Smart Pointers for details.

Step-by-step Sample Code

// First You have to Enable the readers you want to use
// Then You have to Start DATAKIT API
Dtk_API * MyAPI = Dtk_API::StartAPI(TemporaryWorkingDirectory, errorStatus);
Session Context (Dtk_API)
Datakit Libraries and usage
// You open the file and create Document with its assembly tree
Dtk_MainDocPtr inDocument;
err = MyAPI->OpenDocument(inInputFile, inDocument);
File Context (Dtk_MainDoc)
// First we get the root component in the document
Dtk_ComponentPtr RootComponent = inDocument->RootComponent();
// Deal with Dtk_Component tree then for each Prototype get the construction tree
Dtk_ErrorStatus err = MyAPI->ReadComponent(RootComponent, RootNode);
Assembly Tree Context (Dtk_Component)
How to use Assembly Tree
// Deal with Dtk_Node tree then for each Node get associated data
Dtk_BodyPtr TmpBody = RootNode->Get_DtkBodyPtr();
Construction Tree Context (Dtk_Node)
How to use Construction Tree
// We close the opened component
err = MyAPI->EndComponent(inComponent);
// We close the opened document
err = MyAPI->EndDocument(TmpDoc);
// At then end we stop datakit API

Options

Dtk_API options

Dtk_API::EndDocument
Dtk_ErrorStatus EndDocument(Dtk_MainDocPtr &inoutDocument)
Close a Document.
Dtk_API::StartAPI
static Dtk_API * StartAPI(const Dtk_string &inTemporyDirectory, Dtk_ErrorStatus &outErrorCode, const Dtk_string &inCustomerID=Dtk_string())
Start DATAKIT API.
StepReader::Enable
static Dtk_bool Enable()
Dtk_API::EndComponent
Dtk_ErrorStatus EndComponent(Dtk_ComponentPtr &inComponent)
EndComponent release data allocated by ReadComponent or ReadComponentGraphic. You have to call EndCom...
Dtk_API::OpenDocument
Dtk_ErrorStatus OpenDocument(const Dtk_string &inInputFile, Dtk_MainDocPtr &outDocument)
Open a Document (call EndDocument to close it)
CatiaV5Reader::Enable
static Dtk_bool Enable()
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_API::StopAPI
static void StopAPI(Dtk_API *&inAPI, Dtk_bool inWriteTimeInLog=1)
Stop DATAKIT API.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
Dtk_API::ReadComponent
Dtk_ErrorStatus ReadComponent(const Dtk_ComponentPtr &inComponent, Dtk_NodePtr &outRootNode)
Read Component from Assembly Tree (Call EndComponent to free data allocated)
Dtk_API
Definition: dtk_api.hpp:75