static void RivilisCRML()
{
int ibx = 0;
int idx = 0;
double textHeight = 5;
AcGePoint3d point1, point2;
if (acedGetPoint(NULL, _T("\nFirst point: "), asDblArray(point1)) != RTNORM ||
acedGetPoint(asDblArray(point1), _T("\nSecond point: "), asDblArray(point2)) != RTNORM)
return;
AcDbObjectPointer<AcDbMLeaderStyle> pMLStyle(acdbCurDwg()->mleaderstyle(), AcDb::kForRead);
AcDbObjectPointer<AcDbMLeader> pMLeader;
pMLeader.create();
pMLeader->setDatabaseDefaults();
AcDbObjectId leaderId = addToDataBase(pMLeader);
pMLeader->addLeader(ibx);
pMLeader->addLeaderLine(ibx, idx);
pMLeader->addFirstVertex(idx, point1);
pMLeader->addLastVertex(idx, point2);
// pMLeader->setLayer(_T("Leaders"));
pMLeader->setColorIndex(0);
if (point1.x > point2.x)
{
pMLeader->setDoglegDirection(ibx, AcGeVector3d(-1, 0, 0));
pMLeader->setTextAlignmentType(AcDbMLeaderStyle::kRightAlignment);
}
else
{
pMLeader->setDoglegDirection(ibx, AcGeVector3d(1, 0, 0));
pMLeader->setTextAlignmentType(AcDbMLeaderStyle::kLeftAlignment);
}
pMLeader->setTextLocation(point2);
AcDbMText* mText = new AcDbMText();
mText->setDatabaseDefaults();
mText->setContents(_T("TEST"));
mText->setTextStyle(pMLStyle->textStyleId());
mText->setTextHeight(textHeight);
mText->setLineSpacingStyle(AcDb::kExactly);
mText->setLayer(pMLeader->layer());
mText->setColorIndex(0);
pMLeader->setContentType(AcDbMLeaderStyle::kMTextContent);
pMLeader->setMText(mText);
delete mText;
pMLeader->updateLeaderLinePosition();
pMLeader->setTextStyleId(pMLStyle->textStyleId());
pMLeader->setOverride(AcDbMLeader::PropertyOverrideType::kTextStyleId, false);
pMLeader->setMLeaderStyle(acdbCurDwg()->mleaderstyle());
// Указываем MLeaderStyle, что от него зависит MLeader
if (pMLStyle->upgradeOpen() == Acad::eOk)
{
pMLStyle->addPersistentReactor(leaderId);
}
}