设置两个填充颜色相同

void SameHatchColor(AcDbHatch* pTargetHatch,AcDbHatch* pSourceHatch)
{
//填充
Adesk::Boolean GradientOneColorMode;
AcDbHatch::HatchObjectType hatchObjectType;
AcArray<AcCmColor> GradientColors;
AcArray<float> GradientValues;
GradientOneColorMode=pSourceHatch->getGradientOneColorMode();
hatchObjectType=pSourceHatch->hatchObjectType();
unsigned int count=0;
AcCmColor* colors=NULL;
float* values=NULL;
GradientColors.setLogicalLength(0);
GradientValues.setLogicalLength(0);
Acad::ErrorStatus es=pSourceHatch->getGradientColors(count,colors,values);
if(es==eOk&&count>0)
{
for(int i=0;i<count;i++)
{
GradientColors.append(colors[i].colorIndex());
GradientValues.append(values[i]);
}
}
pTargetHatch->setGradientOneColorMode(GradientOneColorMode);
pTargetHatch->setHatchObjectType(hatchObjectType);
hatchObjectType=pTargetHatch->hatchObjectType();
if(!GradientOneColorMode)
{
unsigned int count=GradientColors.logicalLength();
AcCmColor* new_colors=new AcCmColor[count];
float* new_values=new float[count];
for(unsigned int i=0;i<count;i++)
{
new_colors[i]=GradientColors.at(i);
new_values[i]=GradientValues.at(i);
}
pTargetHatch->setGradientColors(count,new_colors,new_values);
#ifdef _WIN64
delete new_colors;
delete new_values;
#else
delete[] new_colors;
delete[] new_values;
#endif
}

}

此条目发表在ObjectArx分类目录。将固定链接加入收藏夹。

发表评论