JA_JERRY 发表于 2005-3-30 21:31:00

[分享]图块插入源码

希望能对大家有用,我花了好久才看懂的,刚学编程不久不要笑我菜,欢迎批评指正


void CTestPlate::OnBlockInsert() <BR>{<BR>        // TODO: Add your control notification handler code here<BR>        acDocManager-&gt;lockDocument(curDoc());<BR>        AcDbObjectId blockId;               //要插入的块的Id值<BR>        AcDbBlockTable *pBlockTable;<BR>        acdbHostApplicationServices()-&gt;workingDatabase()<BR>                -&gt;getSymbolTable(pBlockTable,AcDb::kForRead);<BR>        Acad::eOk!=pBlockTable-&gt;getAt("ASDK-NO-ATTR",<BR>                blockId,AcDb::kForRead)//根据块名获得要插入的块的ID值<BR>        AcDbBlockReference *pBlkRef=new AcDbBlockReference;//插入块实质是插入块的引用<BR>        pBlkRef-&gt;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(&amp;(normal.x),&amp;from,&amp;to,Adesk::kTrue,&amp;(normal.x));//转换函数<BR>        AcGePoint3d basePoint(12,23,0);//指定的插入点(可以根据需要输入)<BR>        //acedGetPoint(NULL,"\nEnter insertion point:",asDblArray(basePoint));<BR>        pBlkRef-&gt;setPosition(basePoint);<BR>        pBlkRef-&gt;setRotation(0.0);<BR>        pBlkRef-&gt;setNormal(normal);<BR>        AcDbBlockTableRecord *pBlockTableRecord;<BR>        pBlockTable-&gt;getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR>        pBlockTable-&gt;close();<BR>        AcDbObjectId newEntId;<BR>        pBlockTableRecord-&gt;appendAcDbEntity(newEntId,pBlkRef);<BR>        pBlockTableRecord-&gt;close();<BR>        pBlkRef-&gt;close();<BR>        acDocManager-&gt;lockDocument(curDoc());<BR>}

我的ARX 发表于 2005-4-1 10:11:00

谢谢楼主!!!

anston 发表于 2005-4-3 16:26:00

正好要用这个功能,先看看再改进一下

578749467 发表于 2010-11-2 18:10:00

<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>

hourui800720 发表于 2011-7-13 23:35:20

谢谢,看下先
页: [1]
查看完整版本: [分享]图块插入源码