- UID
- 3407
- 积分
- 56
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-3-29
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在我这个函数中,能实现填充,但是从设置角度开始,设置的角度,缩放比例,间距,双向都没有反应;但是每一个设置函数返回值都正常的。前面的颜色等都是有用的
/*
EDITION:2K
FUNCTION:roadGreenHatch();
PRAAMETER:AcDbObjectId id
USE:已知id,对其进行填充,该id是封闭的
注意:对其中的填充角度是弧度制;
RETURN ;1:SUCCESSFUL:0:FAIL
PROGRAMED BY WANGQIN
*/
int fast_ent_hatch(HATCHPARAM myHatchParam,AcDbObjectId id,AcDbObjectId & idHatch)
{
int iRz=0;
AcDbHatch* pHatch;
//生成一个填充实体
pHatch = new AcDbHatch();
// 设置填充平面
//
AcGeVector3d normal(0.0, 0.0, 1.0);
iRz=pHatch->setNormal(normal);//平面法线
if(iRz!=Acad::eOk)
{
return 0;
}
iRz=pHatch->setElevation(-0.01);//海拔高度
if(iRz!=Acad::eOk)
{
return 0;
}
//设置填充样式
//
iRz=pHatch->setHatchStyle(AcDbHatch::kNormal);
if(iRz!=Acad::eOk)
{
return 0;
}
//获得该id的顶点集合和突起值集合
AcGePoint3dArray pts;
AcGeDoubleArray blgs;
iRz=GetCurveParam(id,&pts,&blgs);
if(iRz==0)
return 0;
int iL=pts.length();
AcGePoint2dArray vertexPts;
AcGeDoubleArray vertexBulges;
for(int i=0;i<iL;i++)
{
AcGePoint2d g2Tem;
g2Tem.x=pts.at(i).x;
g2Tem.y=pts.at(i).y;
vertexPts.append(g2Tem);
}
for ( i = 0; i < iL; i++)
{
vertexBulges.append(blgs.at(i));
}
//设置边界
iRz=pHatch->appendLoop(AcDbHatch::kExternal, vertexPts, vertexBulges);
if(iRz!=Acad::eOk)
{
return 0;
}
//设置关联
iRz=pHatch->setAssociative(Adesk::kFalse);
if(iRz!=Acad::eOk)
{
return 0;
}
//1、设置颜色
iRz=pHatch->setColorIndex(myHatchParam.iColor);
if(iRz!=Acad::eOk)
{
return 0;
}
//2、设置线宽
iRz=pHatch->setLineWeight((AcDb::LineWeight)myHatchParam.iWeight);
if(iRz!=Acad::eOk)
{
return 0;
}
//3、设置线型比例
iRz=pHatch->setLinetypeScale(myHatchParam.dLineScale);
if(iRz!=Acad::eOk)
{
return 0;
}
//4、设置厚度
//5、设置线型
iRz=pHatch->setLinetype(myHatchParam.szLinetype);
if(iRz!=Acad::eOk)
{
//如果返回为failed,则说明AutoCAD还没有加载该线型
//立刻加载该线型
iRz=LoadSingleLineType(myHatchParam.szLinetype);
if(iRz==0)
{
return 0;
}
iRz=pHatch->setLinetype(myHatchParam.szLinetype);
if(iRz!=Acad::eOk)
{
return 0;
}
}
//6、设置填充类型AcDbHatch::kPreDefined
//7、设置填充图案名称"SOLID"
//Note Be sure to call setPattern() before calling AcDbHatch::evaluateHatch.
iRz=pHatch->setPattern((AcDbHatch::HatchPatternType)myHatchParam.iPatTyle, myHatchParam.szPatName);
if(iRz!=Acad::eOk)
{
return 0;
}
//8、设置旋转角度
//Note Be sure to call setPattern() after using this method in order to update the display.
iRz=pHatch->setPatternAngle(myHatchParam.dAngle);
if(iRz!=Acad::eOk)
{
return 0;
}
//9、设置缩放比例
//Note Be sure to call setPattern() after using this method in order to update the display.
iRz=pHatch->setPatternScale(myHatchParam.dScale);
if(iRz!=Acad::eOk)
{
return 0;
}
//10、设置间距
//Note Be sure to call setPattern() after using this method in order to update the display.
iRz=pHatch->setPatternSpace(myHatchParam.dSpace);
if(iRz!=Acad::eOk)
{
return 0;
}
//11、设置双向
//Note Be sure to call setPattern() after using this method so that the display is updated.
iRz=pHatch->setPatternDouble(myHatchParam.bDouble);
if(iRz!=Acad::eOk)
{
return 0;
}
// Elaborate solid fill
iRz=pHatch->evaluateHatch();
if(iRz!=Acad::eOk)
{
return 0;
}
//加入数据库
iRz=fast_ent_addToDb(pHatch,idHatch);
if(iRz==0)
{
return 0;
}
pHatch->close();
ads_name nmEnt;
acdbGetAdsName(nmEnt,idHatch);
acedRedraw(nmEnt,1);
return 1;
}
|
|