明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1837|回复: 1

[求助]帮我看一下块加属性代码?

[复制链接]
发表于 2007-5-16 14:13:00 | 显示全部楼层 |阅读模式

void insertblock()
{
 AcGePoint3d pt1;
 
 CString blk_name="testblock";
 CString Fname=blk_name+".dwg";
 char sFileName[160];
 const char *dwgName=(LPSTR)(LPCTSTR)Fname;
 acedFindFile(dwgName,sFileName);
 AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse);
 int es=pNewDb->readDwgFile(sFileName ,_SH_DENYNO,false);

 if (es!=Acad::eOk)
 {
 acutPrintf("\nThe file %s cannot be opend",sFileName);
 return;
 }
/////////////////////////////////////////////////////////////////
 AcDbDatabase *pDb;
 pDb =acdbHostApplicationServices ()->workingDatabase () ;

 AcDbObjectId blockId;
 if((es=pDb->insert(blockId, blk_name,pNewDb, true))==Acad::eOk)
 {
 acutPrintf("\ninsert ok\n");
 }
 else
 {
 AfxMessageBox("Insert failed");
 delete pNewDb;
  return;
 }
 if(RTNORM!=acedGetPoint(NULL,"\n请输入插入点:",asDblArray(pt1)))
 {
  return;
 }
 AcDbBlockTable *pBlockTable;
 AcDbBlockTableRecord *pBlockTableRecord;
 acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForRead);


 pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
 pBlockTable->getAt(blk_name, blockId);
 pBlockTable->add(blockId,pBlockTableRecord);
 pBlockTable->close();

 AcDbBlockReference *pBlkRef = new AcDbBlockReference;
 pBlkRef->setBlockTableRecord(blockId);//指向blockId;
 pBlkRef->setPosition(pt1);//设定位置
 pBlkRef->setRotation(0);//设定转角

 AcDbObjectId newEntId;
 pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef);
 pBlockTableRecord->close();
 pBlkRef->close();

 ////////////////////////////////////////////////////////////////////////////
 AcDbBlockTableRecord *pblockrec;
 acdbOpenObject(pblockrec,blockId,AcDb::kForWrite);
 AcDbAttributeDefinition *pAttriDef=new AcDbAttributeDefinition;


 pAttriDef->setPrompt("aa");
 pAttriDef->setTextString("a");
 pAttriDef->setTag("Tag");
 pAttriDef->setInvisible(Adesk::kFalse);
 pAttriDef->setPreset(Adesk::kFalse);
 pAttriDef->setConstant(Adesk::kFalse);
 pblockrec->appendAcDbEntity(newEntId,pAttriDef);
 pAttriDef->close();
 pblockrec->close();

}

插入一个外部块,然后给这个块加块属性,但是属性却看不到,炸开却有块属性在。这是什么问题?

发表于 2007-7-18 11:54:00 | 显示全部楼层

遇到了同样的问题

块里有块,内部块的属性值修改不了。

怎么办?

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 19:50 , Processed in 0.172172 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表