几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-07, 03:24 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】save Gradient Hatches

save gradient hatches
save gradient hatches
hi to all,
i have made a gradient hatch with odamfcapp with the code below:
code:
//test for gradient hatch
oddbobjectid idhatchtemp;
oddbdatabaseptr pdb = this->m_pdb;
{
oddbblocktablerecordptr precord = pdb->getactivelayoutbtrid().safeopenobject(); pdb->getactivelayoutbtrid().safeopenobject(oddb::kforwrite);;
//create new hatch
oddbhatchptr phatch = oddbhatch::createobject();
phatch->setdatabasedefaults(precord->database());
oddbobjectid hatchid = precord->appendoddbentity(phatch);
idhatchtemp = hatchid;
}
{

oddbhatchptr phatch = idhatchtemp.safeopenobject(oddb::kforwrite);
odgevector3d normal(0.0, 0.0, 1.0);
phatch->setnormal(normal);
phatch->setelevation(0.0);
// set non associative hatch
//
phatch->setassociative(false);
// set hatch pattern to solidfill type
//
phatch->setpattern(oddbhatch::kpredefined, "solid");
// set hatch style to knormal
//
phatch->sethatchstyle(oddbhatch::knormal);
// construct hatch external boundary
//
odgepoint2darray vertexpts;
odgedoublearray vertexbulges;
vertexpts.setphysicallength(0).setlogicallength(5);
vertexpts[0].set(2.0, 2.0);
vertexpts[1].set(8.0, 2.0);
vertexpts[2].set(8.0, 8.0);
vertexpts[3].set(2.0, 8.0);
vertexpts[4].set(2.0, 2.0);
vertexbulges.setphysicallength(0).setlogicallength(5);
for (int i = 0; i < 5; i++)
vertexbulges[i] = 0.0;
// append an external loop (rectangle) to hatch boundary
phatch->appendloop(oddbhatch::kpolyline, vertexpts, vertexbulges);
//gradient params
phatch->sethatchobjecttype(oddbhatch::kgradientobject);
phatch->setgradient(oddbhatch::kpredefinedgradient,"spherical");
odcmcolorarray cols;
odgedoublearray vals;
vals.push_back(0.0);vals.push_back(1.0);

odcmcolor color1(odcmentitycolor::kbyaci);
color1.setcolorindex(3);//green
cols.push_back(color1);
odcmcolor color2(odcmentitycolor::kbyaci);
color2.setcolorindex(6);//magenta
cols.push_back(color2);
//rgb colors
////odcmcolor color1(odcmentitycolor::kbycolor);
////color1.setrgb(255,0,0);
////cols.push_back(color1);
////odcmcolor color2(odcmentitycolor::kbycolor);
////color2.setrgb(0,0,255);
////cols.push_back(color2);
assert(cols.size() == vals.size());
phatch->setgradientcolors(2, &cols[0], &vals[0]);
phatch->setgradientonecolormode(false);
phatch->setshadetintvalue(1.0);
phatch->setgradientangle(0.0);
phatch->setgradientshift(0.0);
phatch->evaluatehatch(true);
}
after that i saved the drawing and opened it in acad 2006.
it seems the gradient colors are set to black - rgb 0,0,0. they are set from the code respectively to green and magenta as indexed colors, but they are somehow overwritten.
when i use rgb colors(see the commented code) there are no problems.
so, does it mean that the colors should be always rgb (odcmentitycolor::kbycolor) to be saved correctly?
thanks in advance
nino
file format allows to store gradient colors as index. but for some reason autocad always store them in file as rgb. maybe it will be fixed in ac2007..
sergey slezkin
thanks for the attention!
regards,
nino
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】regenerating associated hatches yang686526 DirectDWG 0 2009-05-07 12:48 PM
【转帖】one color gradient hatch yang686526 DirectDWG 0 2009-05-06 09:22 PM
【转帖】hatching entities yang686526 DirectDWG 0 2009-05-05 12:01 PM
【转帖】gradient in hatches yang686526 DirectDWG 0 2009-05-05 11:39 AM
【转帖】gradient hatches yang686526 DirectDWG 0 2009-05-05 11:39 AM


所有的时间均为北京时间。 现在的时间是 12:31 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多