明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1320|回复: 3

[求助]怎样在图形中插入一个块!

[复制链接]
发表于 2004-3-5 09:39:00 | 显示全部楼层 |阅读模式
我做了一个块NS700.dwg,怎样在新的图形中插入这个块.


thx!

发表于 2004-3-5 11:41:00 | 显示全部楼层
 楼主| 发表于 2004-3-5 14:16:00 | 显示全部楼层
thx
发表于 2004-5-10 08:19:00 | 显示全部楼层
//插入块 void insertBlock(AcGePoint3d basePoint,char *blkname)
{
AcDbObjectId blockId;
AcDbBlockTable *pBlockTable;
if(!hasThisBlock(blkname)){
AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse);
pDb->readDwgFile(blkname);
acdbHostApplicationServices()->workingDatabase()->insert(blockId,blkname,pDb);
delete pDb;
}
else{
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
pBlockTable->getAt(blkname,blockId);
}
AcDbBlockReference *pBlkRef = new AcDbBlockReference;
pBlkRef->setBlockTableRecord(blockId); struct resbuf to, from;
from.restype = RTSHORT;
from.resval.rint = 1; // UCS
to.restype = RTSHORT;
to.resval.rint = 0; // WCS
AcGeVector3d normal(0.0, 0.0, 1.0);
acedTrans(&(normal.x), &from, &to, Adesk::kTrue, &(normal.x));
pBlkRef->setPosition(basePoint);
pBlkRef->setRotation(0.0);
pBlkRef->setNormal(normal); AcDbObjectId newEntId;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForWrite);
pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef); pBlockTableRecord->close();
pBlockTable->close(); pBlkRef->close();

} 调用 char *block_name="c:\\arxprjmfc\\heada.dwg";
char tbuf[80];
AcGePoint3d pt1; if(acedFindFile(head_name,tbuf)!=RTNORM) { //在盘上查找图块
sprintf(tbuf,"file <%s> not existed.",block_name);
acedAlert(tbuf);
return RTERROR;
}
else{
pt1[X]=0.0;
pt1[Y]=0.0;
pt1[Z]=0.0;
insertBlock(pt1,head_name);
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 03:29 , Processed in 0.145538 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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