Create BlendElem Elements in BimRV

Dmytro Hurin

August 13, 2020

An OdBmBlendElem element is a form that is created with two loops. The first one is a top contour and the second one is a bottom contour. Additionally, you can use your own set of vertex connections, which connects the bottom contour with the top contour. Otherwise, default vertex mapping is used.

To create a simple OdBmBlendElem using ODA BimRV:

  1. Load a family (.rfa) file.
  2. Get a valid sketch plane from the database.
  3. Create two closed contours (they must lie on the same plane).
  4. Create a set of vertex connections or use an empty one.
  5. Create a new OdBmBlendElem element.
  6. Set start and end params for OdBmBlendElem.
  7. Open a transaction.
  8. Add the created element to the database.
  9. Commit the transaction.
  10. Save the file.

Let’s look more closely using an example. Code examples that are shown below are from the Examples/TB_DevGuideCommands/BmBlendCreateCmd.cpp file. Using that command, you can create an OdBmBlendElem in the OdaBimApp Debug application.

Open a template or existing family file

For example:

OdBmDatabasePtr pDb = app.readFile(L”blendExample.rfa”);

Get a valid sketch plane from the database

In our command example, we get the sketch plane from the contour that we selected as a bottom contour (sketch plane is the same for both contours).

OdBmObjectId idSketchPlane;
  bool isSetSketchPlaneId = false;
  OdArray<OdBmCurveElemPtrArray>  aCurveSegments;
  //bot curveSegments;
    OdBmCurveElemPtrArray botCurveSegments;
    OdBmSelectionSetIteratorPtr pItSS = pSet->newIterator();
    while (!pItSS->done())
      OdBmCurveElemPtr pCurve = OdBmCurveElem::cast(pItSS->objectId().openObject());
      if (!pCurve.isNull())
        if (!isSetSketchPlaneId)
          idSketchPlane = pCurve->getSketchPlaneId();
          isSetSketchPlaneId = true;

Create a set of vertex connections or use an empty one

Our example does not use custom vertex mapping.

Create two contours

The code section above shows that we get curves that were already created in a file. But when you create a contour yourself, it must be closed and not have intersections. Curves are formed in loops in the code section below:

for (OdUInt32 iLoop = 0; iLoop < arrProfile.size(); iLoop++)
    OdBmGCurvePtrArray aCurvesOfLoop = arrProfile[iLoop];

    OdBmCurveLoopPtr pCurveLoop = OdBmCurveLoop::createObject();
    for (OdUInt32 iCurve = 0; iCurve < aCurvesOfLoop.size(); ++iCurve)
      OdResult res = pCurveLoop->append(aCurvesOfLoop[iCurve]);
      if (res != eOk)
        pIO->putString(OD_T("Invalid CurveLoops"));

Create a new OdBmBlendElem object

OdBmBlendElemPtr pBlendElem = OdBmBlendElem::createObject();

Open a transaction

In the opened transaction, add the newly created pBlendElem to the database, set the start and end parameters, and then call a method to create blend geometry.

double thickness = pIO->getReal("Enter thickness of blend:", OdEd::kInpDefault, 30.0);
  	pBlendElem->setParam(OdBm::BuiltInParameter::BLEND_START_PARAM, 0.0);
  	pBlendElem->setParam(OdBm::BuiltInParameter::BLEND_END_PARAM, thickness);
  	pBlendElem->createBlend(aCurveLoops[0], aCurveLoops[1], idSketchPlane,       

In our command, we get the thickness of the blend from the keyboard. Now let’s describe a signature of createBlend.

OdResult createBlend(const OdBmCurveLoopPtr &baseCurveLoop, const OdBmCurveLoopPtr &topCurveLoop, OdBmObjectId sketchPlaneId, const OdBmVtxConnectionsPtr &connections);

For the first argument we pass the bottom loop with curves; for the second argument, the top loop with curves. In this example we use the sketch plane ID that we got from the bottom loop that we selected during execution of our command in OdaBimApp. And for vertex connections, we pass an empty array.

If the transaction completes without any errors, the blendElem is successfully created. Now you can save this database to a new file with any name.