The Three.js export TX module exports graphical data from .dwg drawing file format to Three.js (JSON) format.
TD_ThreejsJSONExport_xx.yy_zz.tx
where:
The module exposes a single interface ThreejsJSONModule with a single
method exportThreejsJSON()
.
The Three.js export TX module is a single support module for the Drawings SDK, and it's available in dynamic and static forms for Windows, Linux, and macOS (x86 and x64 versions). All source is available in the release packages.
For dynamic (.dll) configurations, the Three.js export TX module can be loaded dynamically; it does not need to be linked to. For static configurations, the Three.js export module should be linked to.
There is only an abstract class that can be inherited by classes that implement their own algorithm of Three.js export: ThreejsJSONModule.
The import process commonly consists of three steps:
exportThreejsJSON()
method of the Three.js export module.Before following the previous steps, some preliminary actions must be performed, including creating a custom services object and initializing it:
// Create a custom Services object.
OdStaticRxObject svcs;
// Initialize Teigha.
odInitialize(&svcs);
To create the Three.js export module, call the method loadModule()
of the odrxDynamicLinker
object. The loadModule()
method returns a smart pointer to the export module
(the export module object is an instance of the class inherited from the ThreejsJSONModule
class).
// Load the Three.js export TX module
ThreejsJSONModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdThreejsJSONExportModuleName, false);
To export a .dwg database to Three.js format, use the exportThreejsJSON()
method
of the export module.
exportThreejsJSON(OdDbBaseDatabase *pDb, OdStreamBuf *pOutStream, const ODCOLORREF &background, bool bFacesEnabled = false);
Parameters:
pDb
— Pointer to the OdDbBaseDatabase
object with the .dwg database to be exported.pOutStream
— The output stream (files stream, memory stream).background
— The color of the scene background.bFacesEnabled
— Defines whether faces are exported (if "true
")
or only lines and points (if "false
").It is implied that the .dwg database already exists. For example, it can be created by loading it from a .dwg file:
OdDbDatabasePtr pDb = svcs.readFile(dwgPath); //dwgPath contains full path to the input .dwg file
Also there must be a stream for the output to be sent to, for example, a file:
// Create the output file
OdStreamBufPtr file = svcs.createFile("output.json", Oda::kFileWrite, Oda::kShareDenyNo, Oda::kCreateAlways);
Now the export can be done by calling the exportThreejsJSON()
method.
ODCOLORREF background = 0;
// Export a DWG database to Three.js format
OdResult exportResult = pModule->exportThreejsJSON(pDb, file, background, true);
Additionally, the function exportThreejsJSON()
defined in the TD_THREEJSJSON_EXPORT
namespace can be used for the export. When using this function, there is no need
to create a Three.js export module.
#include "ThreejsJSONExport.h"
using namespace TD_THREEJSJSON_EXPORT;
// Export a DWG database to Three.js format
OdResult exportResult = exportThreejsJSON(pDb, file, background, true);
The exportResult
variable is of the OdResult type.
The "eOk" export result indicates a successful export process.
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|