Hello everybody . I got a question . So that now I'm creating leader with annotation(Mtext).
The source code is like below .I used "pLeader->attachAnnotation(pMtext->objectID) " but it didn't work.Can you tell me why ?
about Command 's result, I also attached the image below . Please see it.
void
cmdKRLE()
{
ads_point pt0,pt1, pt2;
TCHAR Content[100];
pt0[0] = 0;
pt0[1] = 0;
pt0[2] = 0;
acedInitGet(1, NULL);
acedGetPoint(pt0, _T("\n Select the first point:"), pt1);
acedInitGet(1, NULL);
acedGetPoint(pt1, _T("\n Select the second point:"), pt2);
acdbUcs2Wcs(pt1, pt1, false);
acdbUcs2Wcs(pt2, pt2, false);
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus es;
AcDbBlockTableRecordPointer pBtr(pDb->currentSpaceId(), AcDb::kForWrite);
if (pBtr.openStatus() != Acad::eOk) return;
struct resbuf DimScale;
acedGetVar(_T("DIMSCALE"), &DimScale);
acedGetString(1, _T("\n Input content:"), Content);
AcDbObjectPointer <AcDbMText> pMtext;
pMtext.create();
pMtext->setContents(Content);
pMtext->setLayer(_T("TEXT"));
pMtext->setTextHeight(DimScale.resval.rreal * 3.2);
pMtext->setLocation(asPnt3d(pt2));
if (pt2[0] >= pt1[0])
{
pMtext->setAttachment(AcDbMText::kBottomLeft);
}
else
{
pMtext->setAttachment(AcDbMText::kBottomRight);
}
es = pBtr->appendAcDbEntity(pMtext);
if (es != Acad::eOk)
{
acutPrintf(_T("\n Can not add Mtext!"));
return;
}
AcDbObjectPointer<AcDbLeader> pLeader;
pLeader.create();
pLeader->appendVertex(asPnt3d(pt1));
pLeader->appendVertex(asPnt3d(pt2));
es = pBtr->appendAcDbEntity(pLeader);
if (es != Acad::eOk)
{
acutPrintf(_T("\n Can not add Leader!"));
return;
}
pLeader->setLayer(_T("SCALE"));
pLeader->setDimscale(DimScale.resval.rreal);
pLeader->attachAnnotation(pMtext->objectId());
pLeader->evaluateLeader();
}