cad新学生 发表于 2009-11-23 18:15:00

[求助]插入指定图形数据库块问题

<p>AcDbObjectId CDraw::CreateBlock(AcDbDatabase *pDb,CString blkName,AcGePoint3d origin,int num,...)<br/>{<br/>&nbsp;// 获得当前图形数据库的块表<br/>&nbsp;AcDbBlockTable *pBlkTbl;<br/>&nbsp;/*acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp;&nbsp;-&gt;getBlockTable(pBlkTbl, AcDb::kForWrite);*/<br/>&nbsp; pDb-&gt;getSymbolTable(pBlkTbl, AcDb::kForRead);<br/>&nbsp;// 创建新的块表记录<br/>&nbsp;AcDbBlockTableRecord *pBlkTblRcd;<br/>&nbsp;pBlkTblRcd = new AcDbBlockTableRecord();<br/>&nbsp;/* AcDbBlockTableRecord *pBlkTblRcd;<br/>&nbsp; pBlkTbl-&gt;getAt(ACDB_MODEL_SPACE,pBlkTblRcd,AcDb::kForWrite);*/</p><p>&nbsp;// 根据用户的输入设置块表记录的名称<br/>&nbsp;//char blkName;<br/>&nbsp;//if (acedGetString(Adesk::kFalse, "\n输入图块的名称:", blkName) !=<br/>&nbsp;//&nbsp;RTNORM)<br/>&nbsp;//{<br/>&nbsp;//&nbsp;pBlkTbl-&gt;close();<br/>&nbsp;//&nbsp;delete pBlkTblRcd;<br/>&nbsp;//&nbsp;return;<br/>&nbsp;//}<br/>&nbsp;pBlkTblRcd-&gt;setName(blkName);<br/>&nbsp;// 将块表记录添加到块表中<br/>&nbsp;AcDbObjectId blkDefId;<br/>&nbsp;pBlkTblRcd-&gt;setOrigin(origin);<br/><font color="#ee3d11">&nbsp;pBlkTbl-&gt;add(blkDefId, pBlkTblRcd);&nbsp;//为什么运行到这出错,提示eNotOpenWrite?高手帮帮忙?</font><br/>&nbsp;pBlkTbl-&gt;close();<br/>&nbsp;// 向块表记录中添加实体<br/>&nbsp;AcDbObjectId entId;<br/>&nbsp;va_list pa;<br/>&nbsp;va_start( pa, num );&nbsp;&nbsp;&nbsp;&nbsp; /* Initialize variable arguments. */<br/>&nbsp;for(int i=0;i&lt;num;i++)<br/>&nbsp;{<br/>&nbsp;&nbsp;AcDbEntity *pEnt;<br/>&nbsp;&nbsp;pEnt = va_arg( pa, AcDbEntity*);<br/>&nbsp;&nbsp;pBlkTblRcd-&gt;appendAcDbEntity(entId, pEnt);<br/>&nbsp;&nbsp;pEnt-&gt;close();<br/>&nbsp;}<br/>&nbsp;va_end( pa );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;// 关闭实体和块表记录<br/>&nbsp;pBlkTblRcd-&gt;close();<br/>&nbsp;return blkDefId;<br/>}</p>

luowy 发表于 2009-11-25 17:44:00

<p><font color="#ee3d11">&nbsp;pBlkTbl-&gt;add(blkDefId, pBlkTblRcd);&nbsp;//为什么运行到这出错,提示eNotOpenWrite?高手帮帮忙?</font><br/></p><p>你的块表打开的状态不是【写】的!</p>

cad新学生 发表于 2009-11-27 17:53:00

<p>谢谢!已解决~</p>
页: [1]
查看完整版本: [求助]插入指定图形数据库块问题