- UID
- 236188
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-4-1
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在使用AcdbHatch对一个3dPolyline(一个3dPolyline的正方形,正方形的坐标点的z值不同但是却同一个平面上)进行填充的时候,与使用BHatch命令填充出来的效果不同。使用BHatch命令填充出来的hatch与3dPolyline完全重合,而使用AcdbHatch填充出来的hatch与3dPolyline的就不重合。不过我试了很多方法都不行。由于BHatch命令太慢还不能用它来进行填充。请问那位高人有方法解决这个问题谢谢。
下面是使用AcdbHatch填充的代码:
- [FONT=courier new]
- int MakeHatch
- (
- ads_name entRectangle, ads_point ptView
- )
- {
- AcDbObjectIdArray dbObjIds;
- AcDbObjectId lineId;
- AcDbObjectId pHatchId;
- AcDbBlockTable *pBlockTable = NULL;
- AcDbBlockTableRecord *pBlockTableRecord = NULL;
- AcDbHatch* pHatch = NULL;
- struct resbuf viewrb;
- try{
- ads_command(RTSTR, L"ucs",RTSTR,L"w",0);
- acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead);
- pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
- pBlockTable->close();
- ads_point result;
- pHatch = new AcDbHatch();
- AcDb3dPolyline *p3dline;
- acdbGetObjectId(lineId, entRectangle);
- acdbOpenObject(p3dline, lineId, AcDb::kForRead);
- AcDbObjectIterator* vertexIter = p3dline->vertexIterator();
- p3dline->close();
- if (vertexIter == NULL)
- return FALSE;
- AcGePoint3dArray pointArray;
- AcDb3dPolylineVertex* vertex;
- for (; !vertexIter->done(); vertexIter->step()) {
- if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) {
- if (vertex->vertexType() != AcDb::k3dControlVertex)
- pointArray.append(vertex->position());
- vertex->close();
- }
- }
- delete vertexIter;
- ads_point p1,p2,p4;
- p1[0] = pointArray[0].x;
- p1[1] = pointArray[0].y;
- p1[2] = pointArray[0].z;
- p2[0] = pointArray[1].x;
- p2[1] = 0;
- p2[2] = 0;
- p4[0] = pointArray[3].x;
- p4[1] = 0;
- p4[2] = 0;
- ads_command(RTSTR, L"ucs",RTSTR, L"n", RTSTR, L"3",RT3DPOINT, p1, RT3DPOINT, p2, RT3DPOINT, p4, 0);
- AcGeVector3d normal(0.0, 0.0, 1.0);
- resbuf to,from;
- from.restype=RTSHORT;
- from.resval.rint=1;
- to.restype=RTSHORT;
- to.resval.rint=0;
- acedTrans(&(normal.x),&from,&to,Adesk::kTrue,&(normal.x));
- pHatch->setNormal(normal);
- pHatch->setElevation(0.0);
- pHatch->setPattern(AcDbHatch::kPreDefined, L"SOLID");
- pHatch->setAssociative(Adesk::kTrue);
- acdbGetObjectId(lineId, entRectangle);
- dbObjIds.append(lineId);
- pHatch->appendLoop(AcDbHatch::kExternal, dbObjIds);
- pBlockTableRecord->appendAcDbEntity(pHatchId, pHatch);
- pHatch->evaluateHatch();
- pHatch->close();
- pBlockTableRecord->close();
- return 1;
- }
- catch(...) {
- if(pBlockTable != NULL) {
- pBlockTable->close();
- }
- if(pBlockTableRecord != NULL) {
- pBlockTableRecord->close();
- }
- if(pHatch != NULL) {
- pHatch->close();
- }
- return 0;
- }
- }
- [/FONT]
复制代码 |
|