Creating HoleChartOrigin in Teigha Mechanical

Alexandr Matvienko

August 08, 2017

In Teigha Mechanical, HoleChartOrigin is a part of the HoleChart complex entity. Creation of HoleChartOrigin is the first thing to do to make all components of HoleChart work correctly.


Use AcMgDimManager to create AcAmgHoleChartOrigin and then set its position.

AcMgDimManager manager;
AcAmgHoleChartOriginPtr pHCO;
manager.newHoleChartPoint(pHCO, pDb, btrId, FHCId);
pHCO->setOrigin(OdGePoint3d(65.0, 300.0, 0.0));

The arguments for newHoleChartPoint are as follows:

  • pHCO — A HoleChartOrigin smart pointer
  • pDb — A database pointer
  • btrId — A block table row, which will contain the HoleChartOrigin, then the OdDbObjectId for AcAmgFilteredHoleChart
  • FHCId — A bool flag that is true by default and indicates that you are creating a HoleChartOrigin and not a HoleChartPoint

HoleChartOrigin contains two independent coordinate system layers: cartesian and polar. These layers have their own properties, such as text properties (height, color, attachment point) and HoleChartOrigin components (terminator and arrows of the coordinate system). A cartesian coordinate system is used by default. To set text properties, use the following code:

pHCO->setTextPosition(OdGePoint3d(85.0, 320.0, 0.0));
pHCO->setTextHeight(7.0, AcMgHc::kCartesian);
pHCO->setTextColor(OdCmColor(OdCmEntityColor::kByLayer), AcMgHc::kCartesian);

You can configure properties for a polar coordinate system using the AcMgHc::kPolar enumeration and then switch to a polar coordinate system:


You can also configure the terminator type and visibility of different components:

pHCO->setOriginTerminator(AcMgHc::kPoint2d, AcMgHc::kCartesian);
pHCO->setOriginFlags(SHOWZERO | SHOWCOORDSYSTEM, AcMgHc::kCartesian);

There are seven types of origin terminators:

  • text
  • kNone
  • kPoint2d
  • kDot
  • kDotBlank
  • kCross
  • kNc
  • kCustom

Origin flags is a bit mask that sets the visibility of components:

  • SHOWCOORDSYSTEM — Visibility of origin arrows.
  • SHOWZERO — Visibility of “0” text.
  • DRAWLEADER — Used by HoleChartPoint to set visibility of leaders.

You can set origin text via AcAmgFilteredHoleChart:

OdDbObjectPtr pObj = FHCId.safeOpenObject(OdDb::kForWrite);
AcAmgFilteredHoleChartPtr pFHC = AcAmgFilteredHoleChart::cast(pObj);
pFHC->setColumnEquation(AcMgHc::kHcOrigin, L"MyStr");

The last step is setting the layer for HoleChartOrigin: