- UID
- 121108
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-4-4
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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类模板不好理解
最好能帮助帮助注释一下
谢谢 |
|