将块中的文字设置成属性,即实现块中文字可拖动的功能

bool CInsertTyDlg::AlterDefinition(AcDbBlockReference *pRef, AcDbObjectId objId)
{
AcDbBlockTableRecord *pBlkTabRcd = NULL;
acdbOpenObject(pBlkTabRcd, objId, AcDb::kForWrite);
if (pBlkTabRcd->hasAttributeDefinitions())
{
AcDbBlockTableRecordIterator *pItr = NULL;
pBlkTabRcd->newIterator(pItr);
AcDbEntity *pEnt = NULL;
for (pItr->start(); !pItr->done(); pItr->step())
{
pItr->getEntity(pEnt, AcDb::kForWrite);
AcDbAttributeDefinition *pAttDef = NULL;
pAttDef = AcDbAttributeDefinition::cast(pEnt);
if (pAttDef != NULL)
{
AcDbAttribute *pAtt = new AcDbAttribute();
pAtt->setPropertiesFrom(pAttDef);
pAtt->setInvisible(pAttDef->isInvisible());
AcGePoint3d ptBase = pAttDef->position();
ptBase += pRef->position().asVector();
pAtt->setPosition(ptBase);
pAtt->setHeight(pAttDef->height());
pAtt->setRotation(pAttDef->rotation());
pAtt->setTag(pAttDef->tag());
CString str = pAttDef->textString();
pAtt->setTextString(str);
pRef->appendAttribute(pAtt);
pAtt->close();
}
pEnt->close();
pAttDef->close();
}
delete pItr;
}
pRef->close();
pBlkTabRcd->close();
return true;
}

 

AcDbAttributeDefinition *pAttDef = new AcDbAttributeDefinition();
pAttDef->setPosition(ptInsert);
pAttDef->setTag(strProperty);
pAttDef->setTextString(strValue);
pAttDef->setTextStyle(textId);
pAttDef->setHeight(pText->height());
pBlkTabRcd->appendAcDbEntity(pAttDef);
pAttDef->close();
pText->erase();

 

转载于:https://www.cnblogs.com/xzh1993/p/5032975.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值