Now , i'll read that array path .
AcDbObjectId networkId = AssocUtils::getAssocNetwork(false, UtilFunctions::getBlockRecordId(ACDB_MODEL_SPACE));
if(networkId != AcDbObjectId::kNull)
{
AcDbObjectPointer<AcDbAssocNetwork> pNetwork(networkId, kForRead);
if (pNetwork.openStatus() != eOk)
return false;
const AcDbObjectIdArray& actionsInNetwork = pNetwork->getActions();
for (int nCount = 0; nCount < actionsInNetwork.length(); nCount++)
{
const AcDbObjectId& actionId = actionsInNetwork[nCount];
if (actionId == AcDbObjectId::kNull)
continue;
AcDbObjectPointer<AcDbAssocAction> pAction(actionId, kForRead);
if (pAction.openStatus() != eOk)
continue;
AcDbAssocAction *pAcation = pAction.object();
AcDbObjectId id = pAcation->actionBody();
AcDbHardOwnershipId OwnershipId (id);
AcDbObjectPointer<AcDbObject>pObj(OwnershipId,AcDb::kForWrite);
CString s = pObj->isA()->name();
/////////////
const AcDbAssocArrayActionBody *pArrayActionBody = AcDbAssocArrayActionBody::cast(pObj);
const AcDbAssocArrayParameters *pArrayParameters = pArrayActionBody->parameters();
AcDbObjectIdArray ids = pArrayActionBody->getSourceEntities();
AcDbObjectPointer<AcDbEntity> pEnt(ids[0],AcDb::kForWrite);
AcDbLine *pline = AcDbLine::cast(pEnt);
AcGePoint3d startP = pline->startPoint();
AcGePoint3d EndP = pline->endPoint();
AcDbVertexRef vertexRef ;
AcGePoint3d position;
es = pArrayActionBody->getSourceBasePoint(vertexRef,position);
}
} I get source entities .It is not origin source entities ! Because ( startP , EndP ) are other values .How do I can get correct source entities ?
Is correct the path to get AcDbAssocArrayActionBody ? It is begin at getAssocNetwork ,etc ...
And I get the base point (X= 22.5554 Y= 7.5861 Z= 0.0000) .Base point is position !
Temporary forget source entities is not correct . Now I'll redraw that array path .
AcDbLine *pPath = new AcDbLine(AcGePoint3d( 26.9032 , 12.3896 , 0.0000),AcGePoint3d(22.5554 , 7.5861 , 0.0000));
AcDbLine *pSource = new AcDbLine(AcGePoint3d( 19.5580 , 11.8961 , 0.0000),AcGePoint3d(17.7793 , 8.2770 , 0.0000));
AcDbObjectId idSource = UtilFunctions::postToDb(pSource);
AcDbObjectId idPath = UtilFunctions::postToDb(pPath);
AcDbObjectIdArray sourceEntites;
sourceEntites.append(idSource);
AcDbVertexRef basePoint(AcGePoint3d(22.555400,7.586100,0.000000));
AcDbEdgeRef edge(pPath);
double itemSpacing = 4;
double rowSpacing = 5.42865;
double levelSpacing = 1;
int itemCount = 2;
int rowCount = 1;
int levelCount = 1;
double rowElevation = 0;
AcDbAssocArrayPathParameters *pPathParameters = new AcDbAssocArrayPathParameters(itemSpacing,rowSpacing,levelSpacing,
itemCount,rowCount,levelCount,rowElevation);
pPathParameters->setPath(edge);
pPathParameters->setMethod(AcDbAssocArrayPathParameters::kMeasure);
pPathParameters->setPathDirection(false);
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus es ;
AcDbObjectId arrayId;
AcDbObjectId actionBodyId;
es = AcDbAssocArrayActionBody::createInstance (sourceEntites,basePoint,pPathParameters,arrayId,actionBodyId);
bool k = AcDbAssocManager::evaluateTopLevelNetwork(pDb,NULL,0);
Code for UtilFunctions::postToDb
AcDbObjectId postToDb(AcDbEntity* pEnt)
{
Acad::ErrorStatus es;
AcDbObjectId objId;
AcDbBlockTable* pBlockTable = NULL;
if (acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead)== Acad::eOk)
{
AcDbBlockTableRecord* pSpaceRecord = NULL;
CString mode = acdbCurDwg()->tilemode() ? ACDB_MODEL_SPACE : ACDB_PAPER_SPACE ;
es = pBlockTable->getAt( ACDB_MODEL_SPACE,pSpaceRecord,AcDb::kForWrite);
if (es == Acad::eOk)
{
pEnt->setDatabaseDefaults(acdbCurDwg());
pSpaceRecord->appendAcDbEntity(objId, pEnt);
pEnt->close();
pSpaceRecord->close();
}
pBlockTable->close();
}
return objId;
} Finally result : It is unlike with origin . Please explain to me , why is ?
Thanks you !
