yuze1980 发表于 2008-10-27 17:39:00

[求助]一个AcDbTable的问题

<div class="t_msgfont" id="postmessage_8718">我的一个dwg文件里面有个表格(CAD2008)我想将表格的背景颜色去掉<br/>可是没有成功,希望大家帮我找一下原因。代码如下:<br/>&nbsp;&nbsp;// Add your code for command aaArxjxf._tbn here<br/>&nbsp;&nbsp;AcDbBlockTable *pBlkTbl;<br/>&nbsp;&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp; &nbsp;-&gt;getBlockTable(pBlkTbl, AcDb::kForWrite);<br/>&nbsp;&nbsp;// 获得模型空间的块表记录<br/>&nbsp;&nbsp;AcDbBlockTableRecord *pBlkTblRcd;<br/>&nbsp;&nbsp;pBlkTbl-&gt;getAt(ACDB_MODEL_SPACE, pBlkTblRcd,<br/>&nbsp; &nbsp;AcDb::kForWrite);<br/>&nbsp;&nbsp;AcDbBlockTableRecordIterator *pItr; // 块表记录遍历器<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;pBlkTblRcd-&gt;newIterator(pItr);<br/>&nbsp;&nbsp;AcDbEntity *pEnt; // 遍历的临时实体指针<br/>&nbsp;&nbsp;AcCmColor co;<br/>&nbsp;&nbsp;co.setColorIndex(3);<br/>&nbsp;&nbsp;for (pItr-&gt;start(); !pItr-&gt;done(); pItr-&gt;step())<br/>&nbsp;&nbsp;{<br/>&nbsp; &nbsp;// 利用遍历器获得每一个实体<br/>&nbsp; &nbsp;pItr-&gt;getEntity(pEnt, AcDb::kForWrite);<br/>&nbsp; &nbsp;// 对pEnt所指向的实体进行各种编辑<br/>&nbsp; &nbsp;if(pEnt-&gt;isKindOf(AcDbTable::desc())==Adesk::kTrue)<br/>&nbsp; &nbsp;{<br/>&nbsp; &nbsp; acutPrintf(L"找到table");<br/>&nbsp; &nbsp; AcDbTable *pTable=AcDbTable::cast(pEnt);<br/>&nbsp; &nbsp; //改变背景为无色<br/>&nbsp; &nbsp; pTable-&gt;setBackgroundColorNone(true,AcDb::kAllRows);<br/>&nbsp; &nbsp; //设置一个单元格背景为3号颜色<br/>&nbsp; &nbsp; Acad::ErrorStatus es;<br/>&nbsp; &nbsp; es=pTable-&gt;setBackgroundColor(17,2,co);<br/>&nbsp; &nbsp; acutPrintf(L"&nbsp; &nbsp;&nbsp;&nbsp;sdfsdf&nbsp;&nbsp;% table",es);<br/>&nbsp; &nbsp; pTable-&gt;close();<br/>&nbsp; &nbsp;}<br/>&nbsp; &nbsp;<br/>&nbsp; &nbsp;// 注意需要关闭实体<br/>&nbsp; &nbsp;pEnt-&gt;close();<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;pBlkTbl-&gt;close();<br/>&nbsp;&nbsp;pBlkTblRcd-&gt;close();<br/>&nbsp;&nbsp;delete pItr; // 遍历器使用完毕之后一定要删除!<br/>}</div><div class="t_msgfont"></div><div class="t_msgfont">调试的时候没有发现运行错误(&nbsp;&nbsp;&nbsp; es=pTable-&gt;setBackgroundColor(17,2,co);已经执行了),只是没有达到效果,表格的背景颜色没有改变。</div><div class="t_msgfont">不知道为什么?</div>

zhonghua511 发表于 2008-10-28 12:59:00

<p>太历害了,我不会,怎样才能学好二次开发</p>

netthree 发表于 2009-1-22 16:28:00

<div>为了方便,我将es=pTable-&gt;setBackgroundColor(17,2,co);改为es=pTable-&gt;setBackgroundColor(2,2,co);</div><div>最后加下两行代码</div><div><span class="Apple-style-span" style="font-family: simsun; ">actrTransactionManager-&gt;flushGraphics(); /*refresh screen*/</span></div><div>acedUpdateDisplay(); </div><div>运行结果表格CELL(2,2)的背景颜色变为绿色,通过。</div><div><br/></div>
页: [1]
查看完整版本: [求助]一个AcDbTable的问题