- 积分
- 937
- 明经币
- 个
- 注册时间
- 2004-12-30
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
希望能对大家有用,我花了好久才看懂的,刚学编程不久不要笑我菜,欢迎批评指正
void CTestPlate::OnBlockInsert() { // 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()); } |
评分
-
查看全部评分
|