The purpose of a LinearDimension element is to place a dimension (measured distance) between two elements, for example:
- Reference planes
- Reference lines
- Model lines
- Symbolic lines
- Curves in a sketch
- Edges in GenSweep
- Faces in GenSweep
It is important that the elements are parallel to each other.
 
The following is an example of creating a LinearDimension element. First, a LinearDimension element is created between a CurveElem object and a face of an ExtrusionElem object.
OdBmDatabasePtr pDb = app->readFile(L"Family2.rfa");
ODBM_TRANSACTION_BEGIN(t, pDb)
  t.start();
    OdBmGLinePtr pGLine = OdBmGLine::createObject();
    pGLine->set(OdGePoint3d(2.10358711161061, 4.59562230643384, 0), OdGePoint3d(4.65648409172057, 4.59562230643383, 0));
    OdBmGeomRefPtrArray arrGeomRefs;
    {
      OdBmGeomRefPtr pGeomRef = OdBmGeomRef::createObject();
      pGeomRef->set(pDb->getObjectId(OdDbHandle(2842))); // CurveElem
      arrGeomRefs.append(pGeomRef);
    }
    {
      OdBmGeomRefPtr pGeomRef = OdBmGeomRef::createObject();
      pGeomRef->set(pDb->getObjectId(OdDbHandle(2862)), 5); // face of ExtrusionElem
      arrGeomRefs.append(pGeomRef);
    }
    OdBmDBViewPtr pDBView = pDb->getObjectId(OdDbHandle(23)).safeOpenObject();
    OdBmLinearDimStringPtr pLinearDimString = OdBmLinearDimString::createObject();
    pDb->addElement(pLinearDimString);
    TEST_ASSERT(pLinearDimString->set(pDBView, pGLine, arrGeomRefs) == eOk);
  t.commit();
ODBM_TRANSACTION_END()
After execution of this code, a dimension element appears.
 
Next a LinearDimension is created between two CurveElem objects.
OdBmDatabasePtr pDb = app->readFile(L"Family1.rfa");
ODBM_TRANSACTION_BEGIN(t, pDb)
  t.start();
    OdBmPlanePtr pPlane = OdBmPlane::createObject();
    pPlane->set(OdGePoint3d::kOrigin, OdGeVector3d::kXAxis, OdGeVector3d::kYAxis);
    OdBmSketchPlanePtr pSketchPlane = OdBmSketchPlane::createObject();
    OdBmObjectId sketchPlaneId = pDb->addElement(pSketchPlane);
    pSketchPlane->setGeomPlane(pPlane);
    OdBmObjectId arrRefs[2];
    {
      OdBmCurveElemPtr pCurveElem = OdBmCurveElem::createObject();
      arrRefs[0] = pDb->addElement(pCurveElem);
      OdGePoint3d start = OdGePoint3d(5, 5, 0);
      OdGePoint3d end = OdGePoint3d(5, 10, 0);
      pCurveElem->setSketchPlane(sketchPlaneId);
      pCurveElem->createLine(start, end);
    }
    {
      OdBmCurveElemPtr pCurveElem = OdBmCurveElem::createObject();
      arrRefs[1] = pDb->addElement(pCurveElem);
      OdGePoint3d start = OdGePoint3d(10, 5, 0);
      OdGePoint3d end = OdGePoint3d(10, 10, 0);
      pCurveElem->setSketchPlane(sketchPlaneId);
      pCurveElem->createLine(start, end);
    }
    OdBmGLinePtr pGLine = OdBmGLine::createObject();
    pGLine->set(OdGePoint3d(5, 5, 0), OdGePoint3d(10, 5, 0));
    OdBmGeomRefPtrArray arrGeomRefs;
    for (OdUInt8 iIndex = 0; iIndex < 2; iIndex++)
    {
      OdBmGeomRefPtr pGeomRef = OdBmGeomRef::createObject();
      pGeomRef->set(arrRefs[iIndex]);
      arrGeomRefs.append(pGeomRef);
    }
    OdBmDBViewPtr pDBView = pDb->getObjectId(OdDbHandle(23)).safeOpenObject();
    OdBmLinearDimStringPtr pLinearDimString = OdBmLinearDimString::createObject();
    pDb->addElement(pLinearDimString);
    TEST_ASSERT(pLinearDimString->set(pDBView, pGLine, arrGeomRefs) == eOk);
  t.commit();
ODBM_TRANSACTION_END()
 
 
             
            