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