DATAKIT SDK  V2026.4
BillOfMaterialSample/main.cpp File Reference

Functions

int LaunchBillOfMaterialSample (int argc, char **argv)
 
int main (int argc, char **argv)
 
void printUsage (char *executableName)
 

Function Documentation

◆ LaunchBillOfMaterialSample()

int LaunchBillOfMaterialSample ( int  argc,
char **  argv 
)
78 {
79  // Retrieve the current working directory (used as Datakit's working dir).
80 #ifndef Linux
81  wchar_t workingDirectory[1024];
82  _wgetcwd(workingDirectory, 1024);
83 #else
84  char workingDirectory[1024];
85  getcwd(workingDirectory, 1024);
86 #endif
87 
88  std::cout << "Starting DATAKIT API..." << std::endl;
89 
90  // Enable all required readers before starting the API.
91  EnableReaders();
92 
93  // Start the Datakit API.
94  Dtk_ErrorStatus errorStatus = dtkNoError;
95  Dtk_API *myApi = Dtk_API::StartAPI(workingDirectory, errorStatus);
96  if (myApi == NULL)
97  {
98  std::cout << "Error: cannot start DATAKIT API (code: " << errorStatus << ")" << std::endl;
99  return errorStatus;
100  }
101  std::cout << "DATAKIT API started successfully." << std::endl;
102 
103  // Process each input file provided on the command line.
104  int returnCode = 0;
105  for (int i = 1; i < argc; ++i)
106  {
107  Dtk_string inputFile(argv[i]);
108  Dtk_ErrorStatus fileErr = ProcessFile(inputFile);
109  if (fileErr != dtkNoError)
110  returnCode = static_cast<int>(fileErr);
111  }
112 
113  // Stop the Datakit API and release all resources.
114  Dtk_API::StopAPI( myApi );
115  std::cout << std::endl << "DATAKIT API stopped." << std::endl;
116 
117  return returnCode;
118 }

◆ main()

int main ( int  argc,
char **  argv 
)
32 {
33 #ifndef Linux
34  // Change the working directory to "../../bin" on non-Linux systems so that
35  // required Datakit binaries and resources can be found.
36  _wchdir(L"../../bin");
37 #endif
38 
39  if (argc < 2)
40  {
41  printUsage(argv[0]);
42  return 1;
43  }
44 
45  return LaunchBillOfMaterialSample(argc, argv);
46 }

◆ printUsage()

void printUsage ( char *  executableName)
18 {
19  std::cout << "Usage:\n";
20  std::cout << " " << executableName << " <InputFile>\n";
21  std::cout << "\n";
22  std::cout << "Arguments:\n";
23  std::cout << " <InputFile> Mandatory parameter: Path to a CAD assembly or part file\n";
24  std::cout << "\n";
25  std::cout << "Example:\n";
26  std::cout << " " << executableName << " \"../SampleFiles/Assembly.CATProduct\"\n";
27 }
Dtk_API::StartAPI
static Dtk_API * StartAPI(const Dtk_string &inTemporyDirectory, Dtk_ErrorStatus &outErrorCode, const Dtk_string &inCustomerID=Dtk_string())
Start DATAKIT API.
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
LaunchBillOfMaterialSample
int LaunchBillOfMaterialSample(int argc, char **argv)
Definition: BomStartAPI.cpp:77
ProcessFile
static Dtk_ErrorStatus ProcessFile(const Dtk_string &inFilePath)
Definition: BomStartAPI.cpp:21
EnableReaders
void EnableReaders()
Definition: LibReadersSample/RunThroughAPI/GetStarted/EnableReaders.cpp:12
printUsage
void printUsage(char *executableName)
Definition: BillOfMaterialSample/main.cpp:17
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
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
Definition: dtk_api.hpp:75