[分享]图块插入源码
[分享]图块插入源码
希望能对大家有用,我花了好久才看懂的,刚学编程不久不要笑我菜,欢迎批评指正
void ctestplate:

nblockinsert()
{
// todo: add your control notification handler code here
acdocmanager->lockdocument(curdoc());
acdbobjectid blockid; //要插入的块的id值
acdbblocktable *pblocktable;
acdbhostapplicationservices()->workingdatabase()
->getsymboltable(pblocktable,acdb::kforread);
acad::eok!=pblocktable->getat("asdk-no-attr",
blockid,acdb::kforread)//根据块名获得要插入的块的id值
acdbblockreference *pblkref=new acdbblockreference;//插入块实质是插入块的引用
pblkref->setblocktablerecord(blockid);//指定所引用的图块表记录的对象id
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));//转换函数
acgepoint3d basepoint(12,23,0);//指定的插入点(可以根据需要输入)
//acedgetpoint(null,"\nenter insertion point:",asdblarray(basepoint));
pblkref->setposition(basepoint);
pblkref->setrotation(0.0);
pblkref->setnormal(normal);
acdbblocktablerecord *pblocktablerecord;
pblocktable->getat(acdb_model_space,pblocktablerecord,acdb::kforwrite);
pblocktable->close();
acdbobjectid newentid;
pblocktablerecord->appendacdbentity(newentid,pblkref);
pblocktablerecord->close();
pblkref->close();
acdocmanager->lockdocument(curdoc());
}
哈哈,我又回来了。互相学习,共同提高qq:250623330我的群:1083110
【好评】好程序 金钱+1 经验+1 [easypower |
谢谢楼主!!!
正好要用这个功能,先看看再改进一下