几何尺寸与公差论坛------致力于产品几何量公差标准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-06, 11:09 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】problem with colorindex in a ctb file

problem with colorindex in a ctb file
problem with colorindex in a ctb file
we have incorrect value return by odcmentitycolor::colorindex after loading a ctb file.
here the code but i can't upload the ctb file with the problem. i test it in odamfcapp.
code:
void badcolorinplotstyletable()
{
try
{
lpctstr lpcszpathnamectb = "c:\\test.ctb";
odgicontextfordbdatabaseptr odgicontextfordbdatabaseptr = odgicontextfordbdatabase::createobject();
odstreambufptr pfilebuf;

if(theapp.accessfile(lpcszpathnamectb, oda::kfileread))
{
pfilebuf = theapp.createfile(lpcszpathnamectb);
}
if (!pfilebuf.isnull())
{
odgicontextfordbdatabaseptr->loadplotstyletable(pfilebuf);
}
odcmentitycolor odcmentitycolor;
odpsplotstyledata odpsplotstyledata;
oduint8 nred = 0,
ngreen = 0,
nblue = 0;
int ncolorindex = 0;
int iindex;
bool bcolor;
iindex = 1;
odgicontextfordbdatabaseptr->plotstyle(iindex, odpsplotstyledata);
odcmentitycolor = odpsplotstyledata.color();
bcolor = odcmentitycolor.isbycolor();
nred = odcmentitycolor.red();
ngreen = odcmentitycolor.green();
nblue = odcmentitycolor.blue();
ncolorindex = odcmentitycolor.colorindex();
assert(ncolorindex == 95);
iindex = 2;
odgicontextfordbdatabaseptr->plotstyle(iindex, odpsplotstyledata);
odcmentitycolor = odpsplotstyledata.color();
bcolor = odcmentitycolor.isbycolor();
nred = odcmentitycolor.red();
ngreen = odcmentitycolor.green();
nblue = odcmentitycolor.blue();
assert(nred == 78);
assert(ngreen == 188);
assert(nblue == 83);
ncolorindex = odcmentitycolor.colorindex();
}
catch(...)
{
}
}
...
// register dwgdirect
odinitialize(this);
#ifndef _toolkit_in_dll_
odrx_init_static_module_map();
#endif
badcolorinplotstyletable();
commandmacro::rxinit();
...
what is the solution ?

first, you can draw (in autocad) simple dwg file using issued .ctb plotstyle file. then try to render it in odamfcapp. if odamfcapp draws colors correctly - you probably are doing something wrong (and the sample of correct way is odamfcapp :-) ).
if odamfcapp draws colors incorrectly, you can rename issued .ctb file to .zip or .dwg and attach it to forum.
sincerely yours,
george udov

here the ctb file.
odamfcapp draws colors correctly, with this ctb file, but when we load it we have incorrect value return by odcmentitycolor.colorindex().
in my sample at index = 1 colorindex must be 95 or it return 97.
index = 2 must return a true color with red = 78, green = 188 and blue = 83 but the value return by occmentitycolor is red = 82, green = 165 and blue = 82.
i just want to know if there is something wrong with our code ?
attached files (4.2 kb, 6 views)


quote:
originally posted by froggy
in my sample at index = 1 colorindex must be 95 or it return 97.
why color index must be 95? as i understand color 1 is "by color", so you can look up color index in device palette (if you need it); you shouldn't use member colorindex() here since it'll return color index in palette that is used for saving to pre-r15 file (this palette doesn't depend on background color, but palette that is used for rendering must depend on background color).
quote:
originally posted by froggy
index = 2 must return a true color with red = 78, green = 188 and blue = 83 but the value return by occmentitycolor is red = 82, green = 165 and blue = 82.
i reproduced this behaviour. thank you for information - we'll think about it. probably autocad in some cases (e. g. if two neighbour colors are close) post-processes information that is in .ctb file in some manner. we're return exactly that is saved in .ctb.
sincerely yours,
george udov
thanks udov for your quick reply !
quote:
why color index must be 95?
it must be 95 because it's the color index we have selected with autodesk hardcopy plot style table editor when we have created this ctb file.

not at all, froggy.
in autodesk plotstyle editor (exploring file that you attached) for index=1 i see true color (63,127,63), not color index. dd returns same result.
sincerely yours,
george udov
george, you are right !
there is a misunderstanding.
we have created this ctb with autodesk plotstyle editor of autocad 2002 and the values we have selected were different with the values return by occmentitycolor, but if we open the same file with plotstyle editor of autocad 2005 the color values are the same as those returned by occmentitycolor (except for index 2 of my sample).
now i know that the problem doesn't come from odcmentitycolor, maybe it comes from what autodesk save in the ctb.
thank you, george, for answering my questions !!
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】odamfcapp and library ctb problem yang686526 DirectDWG 0 2009-05-06 06:55 PM
【转帖】obtain single sat file for all proxy enitites yang686526 DirectDWG 0 2009-05-06 06:47 PM
【转帖】different vectorization of same file on windows and mac yang686526 DirectDWG 0 2009-05-04 07:29 PM
【转帖】creating a sat file out of dxf solid file yang686526 DirectDWG 0 2009-05-04 06:47 PM


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


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