[分享]图块插入源码
希望能对大家有用,我花了好久才看懂的,刚学编程不久不要笑我菜,欢迎批评指正void CTestPlate::OnBlockInsert() <BR>{<BR> // TODO: Add your control notification handler code here<BR> acDocManager->lockDocument(curDoc());<BR> AcDbObjectId blockId; //要插入的块的Id值<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable,AcDb::kForRead);<BR> Acad::eOk!=pBlockTable->getAt("ASDK-NO-ATTR",<BR> blockId,AcDb::kForRead)//根据块名获得要插入的块的ID值<BR> AcDbBlockReference *pBlkRef=new AcDbBlockReference;//插入块实质是插入块的引用<BR> pBlkRef->setBlockTableRecord(blockId);//指定所引用的图块表记录的对象ID<BR> resbuf to,from;<BR> from.restype=RTSHORT;//插入图块要进行用户坐标与世界坐标的转换<BR> from.resval.rint=1;//UCS<BR> to.restype=RTSHORT;<BR> to.resval.rint=0;//WCS<BR> AcGeVector3d normal(0.0,0.0,1.0);<BR> acedTrans(&(normal.x),&from,&to,Adesk::kTrue,&(normal.x));//转换函数<BR> AcGePoint3d basePoint(12,23,0);//指定的插入点(可以根据需要输入)<BR> //acedGetPoint(NULL,"\nEnter insertion point:",asDblArray(basePoint));<BR> pBlkRef->setPosition(basePoint);<BR> pBlkRef->setRotation(0.0);<BR> pBlkRef->setNormal(normal);<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR> pBlockTable->close();<BR> AcDbObjectId newEntId;<BR> pBlockTableRecord->appendAcDbEntity(newEntId,pBlkRef);<BR> pBlockTableRecord->close();<BR> pBlkRef->close();<BR> acDocManager->lockDocument(curDoc());<BR>} 谢谢楼主!!! 正好要用这个功能,先看看再改进一下 <table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div style="TEXT-INDENT: 0px; WORD-WRAP: break-word; FONT-SIZE: 12pt; OVERFLOW: hidden; WORD-BREAK: break-all" id="textstyle_2">谢谢楼主!!! </div></td></tr></tbody></table> 谢谢,看下先
页:
[1]