Examples

  1. FAQ

How to compute extents for model space?

See AbstractViewPE.h. This protocol extension can be applied to OdDbViewport, OdDbViewportTableRecord, OdDbViewTableRecord.

You can find sample code in Kernel/Examples/Exports/RasterExport. AbstractViewPE in its zoomExtents() and viewExtents() takes into account only visible geometry honoring layers state (if layer is off or frozen).

Do you have any library support to generate 2d .dwg floor plans from ifc files?

In Visualize library you can convert ifc to .vsf and then from .vsf to .dwg. An example of how you can do this is located in /Examples/Ifc2Visualize and /Extensions/Visualize2Dwg

Where I can find information about plot drawings?

For plotting options you can refer to the example in Drawings SDK archive in Drawing\Examples\Qt\OdaQtPlotSettingsValidator.

When using OdCopyEx.cpp to convert the CAD file version, the out of memory dialog box pops up, and the code throws an exception when readFile. Is there any way to solve this problem? The file is less than 50MB.

Dwg file format is highly compressed and drawing occupied much more memory than file size.
Memory limit for 32-bit application is 2G. 64-bit application has no such limitation.
In some scenarios partial loading and paging can reduce memory usage but saving drawing to file require that all data is loaded into memory.

How to ''embed'' images in the drawing?

You can embed image as OLE entity. See /Drawing/Examples/ExCommands/ExInsertRaster.cpp

How do I read in OBJ file data?

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.

Can we get direct polylines like startPoint and EndPoint of dimension/leader/extension lines?

A dimension entity has the method OdDbObjectId dimBlockId(). A block contains all dimension geometry. If any dimension property is changed, this block is recomputed.

You can get simple entities such as lines, multiline text, etc. by iterating through the dimension block.

We need the text string in the form of polylines matching the exact font type used in a .dwg file. Is there a way to get such polylines?

See the implementation of the TxtExp command in Drawings/Examples/ExCommands/ExTxtExp.cpp. It converts text to polylines and arcs.

Is the source code for ODA File Converter available?

You can find this example source code in the Drawings archive: Drawings_XX\Drawing\Examples\Qt\OdaFileConverter.

Can you provide ODA sample code in C# (for how to create circles, arcs, etc.)?

See Drawings.NET\Examples\OdReadExSwigMgd\DbFiller.cs.

Are there command line examples that support Windows and Linux operating systems (.deb) for converting .dwg/.dxf files into .dwg/.dxf/.svg/.png files?

ODA SDKs support numerous formats. Drawings SDK provides native support for .dwg/.dxf file formats and a set of various exports and imports. The Drawings SDK archive includes a set of samples that work at the command line. Here are a few examples related to converting files:

  • OdCopyEx — Loads a .dwg/.dxf file of any version and saves it to a .dwg/.dxf file of any version.
  • OdDwfExport — Loads a .dwg/.dxf file and exports its content to a .dwf file.
  • OdColladaExport — The same, but the output is a Collada file.
  • OdPdfExport — Also the same, but the output is a .pdf file.
  • OdSvgExport — Also the same, but the output is an .svg file.
  • And more.

How do I regen in WPF?

The implementation is:

m_pDevice->invalidate();
if(m_pDevice->gsModel())
m_pDevice->gsModel()->invalidate(OdGsModel::kInvalidateAll);

where m_pDevice is a derivative of the OdGsDevice class.

How do I get geometry from an entity?

See the OdGetGeomEx sample project: \Drawing\Examples\OdGetGeomEx.

What are the differences between OdaMfcApp and ODA Viewer?

  • OdaMfcApp can use the various rendering devices (WinGDI, Silicon Graphics OpenGL®®, Microsoft® DirectX®, Bitmap, GLES2). ODA Viewer uses OpenGL.
  • OdaMfcApp can enable or disable the graphics cache (Tools->Options->Use GS model). ODA Viewer can't disable this option.