How do I read in OBJ file data?

  1. FAQ
  2. »
  3. Examples

The main module project is placed in the Components/OBJToolkit folder. The header file with all needed methods declarations is OBJToolkit.h. To import the .obj file, create an OdObjImport object, call the method importFile and you'll have access to groups and geometrical objects of OdObjDb:

OdObjImportPtr pObjImporter = OBJToolkit::createObjImporter();
pObjImporter->importFile(filePath, &importOptions);
OdObjDbPtr pObjDb = pObjImporter->getObjDb();

The import sample is in the Obj2Visualize project of Components/Examples, and it can be tested in Components/Visualize/Examples/Visualize Viewer (File->Open->Obj).

An example of exporting .dwg to .obj is located in the Drawing/Examples/ExCustObjs project (in the function called _OBJExport_func). This is the OBJExport command of the OdaMfcApp sample application. Another example of exporting into OBJ from Visualize is in Visualize Viewer on the File->Export->Obj menu.