- 积分
- 402
- 明经币
- 个
- 注册时间
- 2004-4-5
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
void lwpoly() { AcDbDatabase *pCurDb; AcDbBlockTable *pBlkTable; AcDbBlockTableRecord *pBlkTableRecord; AcDbPolyline *pPolyEnt; AcDbObjectId polyId; AcGePoint2d pkPt; AcGePoint2dArray arPts; ads_point pick, lastpt; AcGeMatrix3d ucsMat; AcGeMatrix2d ucsMat2d;
int retCode; int numPts;
Adesk::Boolean keepPicking = Adesk::kTrue; Adesk::Boolean firstPick = Adesk::kTrue
acdbUcsMatrix(ucsMat);
ucsMat2d(0,0) = ucsMat(0,0); ucsMat2d(0,1) = ucsMat(0,1); ucsMat2d(0,2) = ucsMat(0,3); ucsMat2d(1,0) = ucsMat(1,0); ucsMat2d(1,1) = ucsMat(1,1); ucsMat2d(1,2) = ucsMat(1,3);
while(keepPicking) { if(firstPick) { retCode = acedGetPoint(NULL, "\nPick first point: ", pick); firstPick = Adesk::kFalse; } else { acdbPointSet(pick, lastpt); retCode = acedGetPoint(pick, "\nPick another point - [ENTER] for no more: ", pick); acedGrDraw(lastpt, pick, 1, 0); } if(retCode != RTNORM) { keepPicking = Adesk::kFalse; break; }
pkPt.x = pick[X]; pkPt.y = pick[Y];
AcGePoint2dArray arPts.append(pkPt); } acedRedraw(NULL, 1); if(arPts.isEmpty()) { acutPrintf("\nEmpty array."); return; }
if(arPts.length() < 2) { acutPrintf("\nArray only contains one point."); return; }
numPts = arPts.length();
pCurDb = acdbHostApplicationServices()->workingDatabase(); pCurDb->getBlockTable(pBlkTable, AcDb::kForRead); pBlkTable->getAt(ACDB_MODEL_SPACE, pBlkTableRecord, AcDb::kForWrite); pBlkTable->close();
pPolyEnt = new AcDbPolyline(numPts); for(int idx = 0; idx < numPts; idx++) { pkPt = arPts.at(idx); pkPt.transformBy(ucsMat2d); pPolyEnt->addVertexAt(idx, pkPt); }
pBlkTableRecord->appendAcDbEntity(polyId, pPolyEnt); pBlkTableRecord->close(); pPolyEnt->close(); }
主要是pPolyEnt = new AcDbPolyline(numPts)前的部分 AcArray类模板不好理解 最好能帮助帮助注释一下 谢谢 |
|