In the following examples, the pLeader variable stores a pointer to the leader object.
A leader can attach to an annotation, which can be one of the following entities: Frame Control Feature (tolerance) (OdDbFcf), multiline text (OdDbMText), or block reference (OdDbBlockReference). When the annotation entity moves, the leader entity recalculates the coordinates of the leader line vertices so that the leader is always connected to the annotation entity.
To check the annotation type, use the annoType() method, which returns the annotation type as a value from the OdDbLeader::AnnoType enumeration.
enum AnnoType {
kMText = 0,
kFcf = 1,
kBlockRef = 2,
kNoAnno = 3
};
For example:
switch (pLeader->annoType())
{
case OdDbLeader::kMText:
{
odPrintConsoleString(L"\nAnnoType is 'MText'");
break;
}
case OdDbLeader::kFcf:
{
odPrintConsoleString(L"\nAnnoType is 'Fcf'");
break;
}
case OdDbLeader::kBlockRef:
{
odPrintConsoleString(L"\nAnnoType is 'BlockRef'");
break;
}
case OdDbLeader::kNoAnno:
{
odPrintConsoleString(L"\nAnnoType is 'NoAnno'");
break;
}
}
To add an annotation to the leader entity, use the attachAnnotation() method, which requires one parameter that can be the Frame Control Feature, multiline text, or block reference. For example:
OdGePoint3d point = OdGePoint3d(0,0,0);
OdDbMTextPtr pMText = OdDbMText::createObject();
pMText->setDatabaseDefaults(pDb);
OdDbObjectId mTextId = bBTR->appendOdDbEntity(pMText);
pMText->setLocation(point);
pMText->setAttachment(OdDbMText::kMiddleLeft);
pMText->setContents(OD_T("MText"));
pLeader->attachAnnotation(mTextId);
To get the size of the annotation, use the annoHeight() and annoWidth() methods, which return width and height of the annotation as double values. For example:
if (pLeader->annoType()!= OdDbLeader::kNoAnno)
odPrintConsoleString(L"\nAnnotation height = %f, Annotation width = %f", pLeader->annoHeight(), pLeader->annoWidth());
This property specifies the vertical justification of the annotation relative to the last point of the leader line. The vertical justification is an integer value:
To get the text position, use the dimtad() method, which returns the vertical text position as an integer value. For example:
switch (pLeader->dimtad())
{
case 0:
{
odPrintConsoleString(L"\nText position type is 'Centered'");
break;
}
case 1:
{
odPrintConsoleString(L"\nText position type is 'Above'");
break;
}
case 2:
{
odPrintConsoleString(L"\nText position type is 'Side'");
break;
}
case 3:
{
odPrintConsoleString(L"\nText position type is 'JIS'");
break;
}
}
To set a new position for annotation text, use the setDimtad() method, which requires one integer parameter to specify the new vertical text position. For example:
// Centered
pLeader->setDimtad(0);
// Above
pLeader->setDimtad(1);
// Side
pLeader->setDimtad(2);
// JIS
pLeader->setDimtad(3);
This property specifies the distance between the last point or hook line and the margin of the annotation entity. If the "Vertical Text Position" is set to "Above", "Side", or "JIS", this property specifies the distance from the hook line to the bottom margin of the annotation entity. If the "Vertical Text Position" is set to "Centered", this property specifies the distance from the last point to the left or right margin of the annotation entity.
If this property is negative, a border is drawn around the annotation entity and its absolute value is used for a gap.
To get the text gap, use the dimgap() method, which returns the text gap as a double value. For example:
odPrintConsoleString(L"\nText gap is %g", pLeader->dimgap());
To set a new text gap, use the setDimgap() method, which requires one double parameter to specify the new text gap value. For example:
pLeader->setDimgap(0.3);
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|