Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can you help me see what the problem is? thank you!
1 . Delete the text in group A1,
2. increase text the arc length ,
3. add the text to group A1(Similar to the group on the right)
static void MSDDMyGroupMyCommand0 () {
ads_name ent;
ads_point pt;
if (RTNORM != acedEntSel(_T("\n选择对象: "),ent,pt))
{
return;
}
AcDbObjectId objId;
acdbGetObjectId(objId,ent);
AcDbEntityPointer pEnt(objId,AcDb::kForRead);
Acad::ErrorStatus es=pEnt.openStatus();
if (Acad::eOk != es)
{
acutPrintf(_T("\nFailed to open object,es=%s"),acadErrorStatusText(es));
return;
}
const AcDbVoidPtrArray *pReactors=pEnt->reactors();
if (pReactors==NULL || pReactors->length()<1)
{
acutPrintf(_T("\nThe object has no groups!"));
return;
}
AcDbObjectIdArray entIds;
for (int i=0;i<pReactors->length();i++)
{
void* pSomething = pReactors->at(i);
if (pSomething==NULL) continue;
if (!acdbIsPersistentReactor(pSomething)) continue;
AcDbObjectId persReactorId=acdbPersistentReactorObjectId(pSomething);
AcDbObjectPointer<AcDbGroup> pGroup(persReactorId,AcDb::kForRead);
pGroup->allEntityIds(entIds);
}
for (int i=0;i<entIds.length();i++)
{
AcDbEntity *pEnt = NULL;
if (acdbOpenObject(pEnt, entIds.at(i), AcDb::kForWrite) == Acad::eOk)
{
if (pEnt->isKindOf(AcDbText::desc()))
{
pEnt->erase();
}
else
{
pEnt->close();
AcDbCurve* pEnt;
double PaPtCen;
AcGePoint3d PtCen;
acdbOpenObject(pEnt, entIds.at(i), AcDb::kForRead);
double startParam, endParam, startDist, endDist;
pEnt->getStartParam(startParam);
pEnt->getEndParam(endParam);
pEnt->getDistAtParam(startParam, startDist);
pEnt->getDistAtParam(endParam, endDist);
double Clength = endDist - startDist;
pEnt->getParamAtDist(Clength * 0.5,PaPtCen);
pEnt->getPointAtParam(PaPtCen,PtCen);
WCHAR s[20];
_swprintf(s, L"L=%0.0f", Clength);
AcDbText *text = new AcDbText(PtCen,s,AcDbObjectId::kNull,80,0);
text->setColorIndex(50);
text->setWidthFactor(0.7);
text->setHorizontalMode(AcDb::TextHorzMode::kTextCenter);
text->setAlignmentPoint(PtCen);
text->setJustification(AcDbText::kTextAlignmentMiddleCenter );
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
AcDbBlockTableRecordPointer pBTR(pDb->currentSpaceId(), AcDb::kForWrite);
if (text && Acad::eOk == pBTR.openStatus()) {pBTR->appendAcDbEntity(text); text->close();}
}
}
pEnt->close();
}
}
Solved! Go to Solution.