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