- UID
- 353383
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-11-19
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我用下面的代码实现任何形状的封闭区域的填充,主要是搜索要填充的区域,然后用polyline生成boundary!代码可以执行,就是填充完后将对polyline进行编辑的时候,autocad 就会出错!各位大侠帮忙看看出什么问题了,谢谢!
//搜索一不铸孔封闭区域并涂黑
void HzBzkFbAreaSearch()
{
AcDbObjectId oldLayerId = acdbCurDwg()->clayer();
HzDefineLayer();
g_bDefineLayer = TRUE;
setCurLayer(g_strLayer_Core);
AcDbObjectId objId,Id,subId;
AcDbObjectIdArray dbObjIds;
AcDbBlockTable *pBlockTable;
AcDbBlockTableRecord *pBlockTableRecord;
if( SearchClosedBoundary( objId ) )
//searchclosedBoundary搜索封闭区域并用多义线覆盖边界,同时返回多义线的Id这个函数绝对没问题
{
AcDbEntity *pEnt ;
if( acdbOpenAcDbEntity( pEnt, objId, AcDb::kForRead ) != Acad:: eOk )
{
acutPrintf("\nOpen it error");
acdbCurDwg()->setClayer(oldLayerId);
return;
}
if( pEnt->isA() == AcDbPolyline::desc() )
{
AcDbPolyline *p = (AcDbPolyline* )pEnt;
if( p->isClosed() == Adesk::kFalse )
{
pEnt->close();
acutPrintf("\nNot closed zone");
acdbCurDwg()->setClayer(oldLayerId);
return;
}
dbObjIds.append(objId);
AcDbHatch* pHatch = new AcDbHatch();
pHatch->setNormal(AcGeVector3d(0.0,0.0,1.0));
pHatch->setElevation(0.0);
pHatch->setAssociative(Adesk::kFalse);
pHatch->setPatternScale(5);
pHatch->setPattern(AcDbHatch::kPreDefined,"SOLID");
pHatch->setHatchStyle(AcDbHatch::kNormal);
pHatch->appendLoop(AcDbHatch::kExternal,dbObjIds);
pHatch->evaluateHatch();
pHatch->setColorIndex(1);
acdbHostApplicationServices()->workingDatabase()//查找并以只读模式
->getSymbolTable(pBlockTable, AcDb::kForRead);//打开图块表
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);//查找并以写模式打开图块表记录(模型空间)
pBlockTable->close();//关闭图块表
pBlockTableRecord->appendAcDbEntity(Id, pHatch);//添加实体返回ID
pBlockTableRecord->close();//关闭图块表记录
pHatch->close();//关闭实体
}
else
{
acutPrintf("\nNot find it ");
pEnt->close();
DeleteEntity( objId );
acdbCurDwg()->setClayer(oldLayerId);
return;
}
}
acdbCurDwg()->setClayer(oldLayerId);
} |
|