Convert Entities to Surfaces

A surface is a 3D object that is an infinitely thin shell. In ODA Software, there are several types of surfaces. The class dependency is shown below.

OdDbSurface

Convert an entity to a surface

The following method converts an entity to surface:

static OdResult createFrom ( const OdDbEntity* pFromEntity, OdDbSurfacePtr& pNewSurface );

The method creates an extruded surface (OdDbExtrudedSurface) from a 2D entity with thickness or creates a planar surface (OdDbPlanarSurface) from a closed curve or region. Just a surface (OdDbSurface) is created for an OdDb3dSolid. In general, this method copies Spatial® ACIS® data from different entities and inserts the data in an OdDbSurface. The parameters are:

  • pFromEntity — Input entity, which can be OdDbCircle, OdDbEllipse, OdDb3dPolyline, OdDb2dPolyline, OdDbPolyline, OdDbSpline, OdDb3dSolid, OdDbSolid, or OdDbRegion.
  • pNewSurface — Resulting surface.

The method returns eOk if a surface was created successfully or an appropriate error code in the other case.

This method is implemented for SpaModeler and for ModelerGeometry.

There is also a thickness parameter that can create an OdDbExtrudedSurface from 2D entities.

Code example:

…
OdDbSurfacePtr pSurface; // resulting surface
OdDbEntityPtr pEntity = pDb->getObject… // input object
OdResult res = OdDbSurface::createFrom(pEntity, pSurface);
…

Example of a 3D Solid Conversion

Here is a 3D solid before conversion to a surface:

3D solid before conversion to a surface

Here is the 3D solid converted to a surface:

3D solid converted to a surface

Example of a Closed Polyline Conversion

Here is a closed polyline with thickness 2.0 before and after conversion to an extruded surface.

a closed polyline with thickness 2.0 before and after conversion to an extruded surface

Example of a Closed Region Conversion

Here is a closed region before and after conversion to a planar surface.

Example of a Closed Region Conversion

Try Conversion using a Sample Command

There is a sample command createSurface available in ExCommands. The sample command allows you to convert different types of entities to a surface. You can select one or more entities and the command calls the OdDbSurface::createFrom(…) method for conversion.

Below is an image that demonstrates conversion of an OdDb3dSolid (the snowman) to a surface.

conversion of an OdDb3dSolid (the snowman) to a surface

Get started today

Try ODA software free for 60 days.
No risk, no credit card required.

Try for Free