tractor 发表于 2007-5-16 17:59:00

高手帮我看看程序吧,在线等,谢谢!

本帖最后由 作者 于 2007-5-16 18:21:32 编辑 <br /><br /> <p></p><p>画了一个正方形,想填充一下,调试通过了,但是已运行arx就报错!高手帮我分析分析吧,多谢了!</p><p></p><p></p><p>Acad::ErrorStatus createSubstationRecord () {</p><p>&nbsp;AcDbHatch* pHatch = new AcDbHatch();</p><p>&nbsp;// Set hatch plane</p><p>&nbsp;AcGeVector3d normal(0.0, 0.0, 1.0);<br/>&nbsp;pHatch-&gt;setNormal(normal);<br/>&nbsp;pHatch-&gt;setElevation(0.0);</p><p>&nbsp;// Set hatch pattern to ANSI31 predefined type<br/>&nbsp;//<br/>&nbsp;pHatch-&gt;setPattern(AcDbHatch::kPreDefined, "ANSI31");</p><p>&nbsp;// Set Associativity<br/>&nbsp;//<br/>&nbsp;pHatch-&gt;setAssociative(Adesk::kTrue);</p><p>&nbsp;AcGePoint3dArray ptSubstation;<br/>&nbsp;ptSubstation.setLogicalLength(4);<br/>&nbsp;ptSubstation.set(0.0,0.0,0.0);<br/>&nbsp;ptSubstation.set(0.0,100.0,0.0);<br/>&nbsp;ptSubstation.set(100.0,100.0,0.0);<br/>&nbsp;ptSubstation.set(100.0,0.0,0.0);</p><p><br/>&nbsp;AcDbObjectId lineId,;<br/>&nbsp;AcDbObjectIdArray dbObjIds;<br/>&nbsp;AcDbLine *pline;</p><p>&nbsp;for (int i = 0; i &lt; 4; i++) {<br/>&nbsp;&nbsp;pline =&nbsp; new AcDbLine();<br/>&nbsp;&nbsp;pline-&gt;setStartPoint(ptSubstation); <br/>&nbsp;&nbsp;pline-&gt;setEndPoint(ptSubstation[(i == 3) ? 0 : i+1]);<br/>&nbsp;&nbsp;postToDatabase(pline, lineId);<br/>&nbsp;&nbsp;dbObjIds.append(lineId);<br/>&nbsp;}<br/>&nbsp;// Append an external rectangular loop to hatch boundary<br/>&nbsp;//<br/>&nbsp;pHatch-&gt;appendLoop(AcDbHatch::kExternal, dbObjIds);<br/>&nbsp;pHatch-&gt;evaluateHatch();</p><p>&nbsp;return Acad::eOk;</p><p>}</p><p>////////下面是Post函数<br/>Acad::ErrorStatus <br/>postToDatabase(/**/AcDbEntity* pEnt,/**/AcDbObjectId&amp; idObj)<br/>{<br/>&nbsp;Acad::ErrorStatus&nbsp;&nbsp; es;<br/>&nbsp;AcDbBlockTable*&nbsp;&nbsp;pBlockTable;<br/>&nbsp;AcDbBlockTableRecord*&nbsp; pSpaceRecord;<br/>&nbsp;//确定当前有正在工作的数据库<br/>&nbsp;if (acdbHostApplicationServices()-&gt;workingDatabase()==NULL)<br/>&nbsp;&nbsp;return Acad::eNoDatabase;<br/>&nbsp;//获得当前图形的指针<br/>&nbsp;//获得图形的块表,打开准备读取数据<br/>&nbsp;if ((es = acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getBlockTable(pBlockTable, AcDb::kForRead))==Acad::eOk){<br/>&nbsp;&nbsp;//获得建模空间的记录,打开准备写数据&nbsp; </p><p>&nbsp;&nbsp;if ((es = pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pSpaceRecord, AcDb::kForWrite))==Acad::eOk){<br/>&nbsp;&nbsp;&nbsp;//添加实体指针到建模空间后关闭指针和建模空间记录</p><p>&nbsp;&nbsp;&nbsp;if ((es = pSpaceRecord-&gt;appendAcDbEntity(idObj, pEnt))==Acad::eOk)<br/>&nbsp;&nbsp;&nbsp;&nbsp;pEnt-&gt;close();<br/>&nbsp;&nbsp;&nbsp;pSpaceRecord-&gt;close();<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;//关闭块表<br/>&nbsp;&nbsp;pBlockTable-&gt;close();</p><p>&nbsp;}<br/>&nbsp;//返回状态信息<br/>&nbsp;return es;<br/>}<br/>/////////////////////<br/></p>

sieben 发表于 2007-5-16 21:15:00

<p>调试通过了????????????????????</p><p>AcDbObjectId lineId,;多一个逗号</p><p>&nbsp;pHatch-&gt;appendLoop(AcDbHatch::kExternal, dbObjIds);<br/>&nbsp;pHatch-&gt;evaluateHatch();</p><p>后面加如下(填充还没有提交到数据库)</p><p>&nbsp;&nbsp;AcDbObjectId hatchId;<br/>&nbsp;&nbsp;postToDatabase(pHatch, hatchId);</p>

tractor 发表于 2007-5-17 13:07:00

<p>谢谢<strong><font face="Verdana" color="#61b713">sieben的回复,帮助很大,但是怎么把花的图形和填充图案,通过程序保存为一个块呢!请求大家帮助</font></strong></p>
页: [1]
查看完整版本: 高手帮我看看程序吧,在线等,谢谢!