for (Adesk::Int32 i = 0; i < numberOfPolylines; i++)
{
if (acedSSName(selectionSet, i, entiyAdsName) != RTNORM)
{
acedSSFree(selectionSet);
return Acad::eUnrecoverableErrors;
}
es = acdbGetObjectId(entityId, entiyAdsName);
if (es != Acad::eOk)
{
//acutPrintf(L"\nНе получен Id");
return es;
}
es = acdbOpenAcDbEntity(pEntity, entityId, AcDb::kForRead);
if (es != Acad::eOk)
{
//acutPrintf(L"\nНе открыть примитив для чтения");
return es;
}
sEntityLayerName = pEntity->layer();
hatchAngle = 0 + rand() % 360;
hatchOptionsMap.insert(std::pair<std::wstring, int>(sEntityLayerName, hatchAngle));
// Используем перегрузку функции AcDbLayerTable::getAt(), которая возвращает ID слоя
es = pLayerTable->getAt (&sEntityLayerName[0], layerId, Adesk::kFalse);
AcDbHatch* pHatch = new AcDbHatch();
// Set hatch plane
AcGeVector3d normal(0.0, 0.0, 1.0);
pHatch->setNormal(normal);
pHatch->setElevation(0.0);
// Set non associative hatch
pHatch->setAssociative(Adesk::kFalse);
// Set hatch pattern to ANSI31 type
pHatch->setPattern(AcDbHatch::kPreDefined, L"ANSI31");
// Set Associativity
pHatch->setAssociative(Adesk::kTrue);
// Set hatch style to kNormal
pHatch->setHatchStyle(AcDbHatch::kNormal);
pHatch->setPatternScale(0.4);
pHatch->setLayer(layerId);
pHatch->setPatternAngle(hatchOptionsMap[sEntityLayerName]);
AcDbObjectIdArray entityIds;
entityIds.append(entityId);
// Append an internal loop (circle) to hatch boundary
pHatch->appendLoop(AcDbHatch::kDefault, entityIds);
// Elaborate solid fill
pHatch->evaluateHatch();
// Get all associative source boundary object Ids for later use.
entityIds.setLogicalLength(0);
pHatch->getAssocObjIds(entityIds);
//pHatch->draw();
//добавляем штриховку к пространству модели
pModelSpaceBlockTableRecord->appendAcDbEntity(hatchId, pHatch);
// Attach hatchId to all source boundary objects for notification.
AcDbEntity *pEnt;
int numObjs = entityIds.length();
for (int j = 0; j < numObjs; j++)
{
es = acdbOpenAcDbEntity(pEnt, entityIds[j], AcDb::kForWrite);
if (es == Acad::eOk)
{
pEnt->addPersistentReactor(hatchId);
pEnt->close();
}
}
pHatch->close();
}
pLayerTable->close();
pModelSpaceBlockTableRecord->close();
pDocumentBlockTable->close();
acDocManager->unlockDocument(pActiveDoc);
return Acad::ErrorStatus::eOk;