- 积分
- 338
- 明经币
- 个
- 注册时间
- 2004-6-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-12-18 13:13:00
|
显示全部楼层
谢谢版主老大,不过还是不行啊完整的源代码如下:- void IteraterPolyline()
- {
- ads_name entName;
- ads_point ptres;
- if( acedEntSel( "\nPlease pick a polyline:", entName, ptres ) != RTNORM )
- {
- acdbFail( "\nFail to select!" );
- return;
- }
-
- AcDb2dPolyline* pPolyline = NULL;
- AcDbObjectId objId;
-
- if( acdbGetObjectId( objId, entName ) != Acad::eOk || !objId.isValid() )
- {
- acdbFail( "\nCan not get object id of selected object!" );
- return;
- }
- // 不是派生类吗?这里为什么不能获取对象的指针
- if( acdbOpenObject( pPolyline, objId, AcDb::kForRead ) != Acad::eOk
- || pPolyline == NULL
- || !pPolyline->isKindOf( AcDb2dPolyline::desc() )
- )
- {
- acdbFail( "\nCan not open open selected object!" );
- return;
- } AcDb2dVertex* pVertex = NULL;
- AcGePoint3d location;
- AcDbObjectId vertexId;
-
- AcDbObjectIterator *pVecIterator = pPolyline->vertexIterator(); for( int vertexNum = 0; !pVecIterator->done(); pVecIterator->step(), vertexNum++ )
- {
- vertexId = pVecIterator->objectId();
- acdbOpenObject( pVertex, vertexId, AcDb::kForRead );
- location = pVertex->position();
- acutPrintf( "\nVertex %d:X[%0.3f], Y[%0.3f], Z[%0.3f]", location[X], location[Y], location[Z] );
- pVertex->close();
- } pPolyline->close();
- delete pVecIterator;
- }
复制代码 我用pl命令在CAD里绘制了一些多段线,不过点选后检测内存发现打开对象的时候pPolyline指针被赋为空,如果我采用 AcDbEntity* pEnt来打开对象则能正常打开.当然,后面对于多段线的操作也就谈不上了.还请版主大哥多多指教,谢谢了! |
|