本帖最后由 BDYCAD 于 2012-10-3 22:29 编辑
- //支持涵数:
- AcDbBlockTableRecord *GetModelSpace(AcDb::OpenMode Mode){
- AcDbDatabase *pDwg = acdbHostApplicationServices()->workingDatabase();
- AcDbBlockTable *pBlockTable;
- AcDbBlockTableRecord *pModelSpace;
- pDwg->getSymbolTable(pBlockTable, AcDb::kForRead);
- pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, Mode);
- pBlockTable->close();
- return pModelSpace;
- }
- //生成PLINE程序示例:
- AcDbObjectId PlineID;
- AcGePoint2d Spt(0,0),Ept(10,50);
- AcGePoint2dArray PointList;
- PointList.append(Spt);
- PointList.append(Ept);
- int PNumber=PointList.length();
- AcDbBlockTableRecord *pModelSpace =GetModelSpace(AcDb::kForWrite);
- AcDbPolyline *newEnt=new AcDbPolyline(PNumber);
- for(int i=0;PNumber>i;i++){
- Spt=PointList.at(i);
- newEnt->addVertexAt(i,Spt);
- }
- pModelSpace->appendAcDbEntity(PlineID,newEnt);
- //if (ClosedObj==TRUE)newEnt->setClosed(Adesk::kTrue);//封闭LWPOLYLINE
- newEnt->close();
- pModelSpace->close();
|