请教各位一个问题【如何删除图块对应的属性】
本帖最后由 netsky2580 于 2015-2-10 08:18 编辑请教各位一个问题:
删除图块对应的属性,下面的程序是否正确
AcDbObjectPointer<AcDbBlockReference> spBlkRef(objId,AcDb::kForWrite);
if(spBlkRef.openStatus() != Mcad::eOk)return;
AcDbObjectIterator* pAttribIter = spBlkRef->attributeIterator();
if(pAttribIter != NULL)
{
for(;!pAttribIter->done();pAttribIter->step() )
{
AcDbObjectPointer<AcDbAttribute> spAttribute(pAttribIter->objectId(),AcDb::kForWrite);
if (spAttribute.openStatus() != Mcad::eOk)
{
continue;
}
spAttribute->erase(true);
spAttribute->close();
}
delete pAttribIter;
}
spBlkRef->close();
按照上面的程序删除后,再用鼠标选择上面的实体会报错,而且再遍历此图块的属性时,它的属性并没有被删除掉,只是spAttribute.openStatus() != Acad::eOk了
采用如下的方式添加的属性:
AcDbAttribute* pAttrib2 = new AcDbAttribute;
AcGePoint3d start1 = spBlkRef->position();
AcGePoint3d start3(start1.x,start1.y-13,0);
pAttrib2->setTag(_T("attrBH"));
pAttrib2->setAlignmentPoint(start3);
pAttrib2->setHorizontalMode(McDb::kTextCenter);
pAttrib2->setTextString(tmpBh);
pAttrib2->setHeight(5);
pAttrib2->setWidthFactor(1);
pAttrib2->setTextStyle(wordsId);
pAttrib2->setInvisible(FALSE);
spBlkRef->appendAttribute(pAttrib2);
pAttrib2->close(); 借到路过,
页:
[1]