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

index color from oddbentity
index color from oddbentity
i want write a function to return index color from oddbentity
for example in "odreadex" i add this function:
short getindexcolor(oddbentity* pent)
{
short colorqd;
odcmentitycolor entcol(0,0,0);
entcol = pent->entitycolor();
if (entcol.isbylayer() ) // color layer
{
oddbobjectid play = pent->layerid(); // layerid
oddblayertablerecordptr player = play.safeopenobject();
colorqd=player->colorindex();
}
else if ( entcol.isbyblock())
{
//oddbobjectid pbl=pent->blockid();
????????
}
else if (entcol.isbyaci())
{
colorqd=entcol.colorindex();
}
if (entcol.isbycolor())
{
// i must create rgb color and convert to the index ok
colorqd=0;
}
return(colorqd);
}
if entcol.isbyblock() is true i don't know how get the index of color.
someone help me?
mission impossible, imho
we already faced with this problem then converted text entities that had attribute "font" by block to acutocad text entities that doesn't support font style by block. it's a ideological problem:
1. attribute "by block" is applicable only if entity is a part of block.
2. but block can has several insertions. color of that insertion you want to get?
for example, you have a block definition with line (color: by block) and two insertion with different colors.
|--------------------------|
| block definition. |
| - line (color: by block) |
|--------------------------|
|------------| |-------------|
| insertion 1| | insertion 2 |
| color: red | | color: green|
|------------| |-------------|
in first insertion line will be red, in second 鈥?green. so you can get color only for line in specified insertion but not for line entity in block definition.
there are two way if your data representation doesn't support property "by block":
1. if you have to get a drawing looks like dwg, you can explode block insertion and then replace color "by block" to real color.
2. if you must leave block (in our case) just return any other color: layer color, black etc.
best regards,
ivan obraztsov
i have to get a drawing like dwg. i try to explode block but i don't obtain real color. example i use odreadex like base.
i try to modify "dumpcommondata":
// dumps common data (for all entities)
void dumpcommondata(oddbentity* pent, std(ostream) & os)
{
oddbhandle htmp;
char buff[20];
htmp = pent->getdbhandle();
htmp.getintoasciibuffer(buff);
odstring st;
st=pent->layer();
oddbobjectid layid=pent->layerid();
oddblayertablerecordptr player = layid.safeopenobject();
short co=player->colorindex();
odstring stc=pent->isa()->name();
cstring stc1="acdbblockreference";
if (stc.c_str()==stc1) // if i am in a acdbblockreference
{
odrxobjectptrarray ptar;
odresult res=pent->explode(ptar);
odrxobjectptr pe=ptar[0];
oddblineptr line=(oddblineptr) pe;
short colorhope=line->colorindex();
}
colorhope is not real color if my first entity in the block are color by block.
you think is possibile modify "odreadex" to obtain real color?
what is my error?
daniele
quote:
originally posted by rareba
i have to get a drawing like dwg. i try to explode block but i don't obtain real color.
if (stc.c_str()==stc1) // if i am in a acdbblockreference
{
odrxobjectptrarray ptar;
odresult res=pent->explode(ptar);
odrxobjectptr pe=ptar[0];
oddblineptr line=(oddblineptr) pe;
short colorhope=line->colorindex();
}
colorhope is not real color if my first entity in the block are color by block.
you think is possibile modify "odreadex" to obtain real color?
what is my error?
daniele
entities in a block table record (i.e. the block definitions) that are marked colorbylayer or colorbyblock do not have a real color until they are instantiated by a block reference (i.e. an insert).
in your code, when you find out that you are looking at an oddbblockreference you must first find out the color of this object and store it. you must also find the layer this reference is placed on and find the colour of that. next when encountering an colour 'byblock' or 'bylayer' you must substitute the relevant colours that you stored.
if (stc.c_str()==stc1) // if i am in a acdbblockreference
{
int layercolor;
int blockcolor;
blockcolor = ent->colorindex(); // this may be color 0 still with nested blocks
oddblayertablerecordptr layer;
layer = ent->layerid().safeopenobject( oddb::kforread );
layercolor = layer->colorindex();
odrxobjectptrarray ptar;
odresult res=pent->explode(ptar);
odrxobjectptr pe=ptar[0];
oddblineptr line=(oddblineptr) pe;
short colorhope=line->colorindex();
if ( colorhope == 0 ) colorhope = blockcolor;
else if ( colorhope == 256 ) colorhope = layercolor;
}
note that for nested blocks (i.e. when you find a oddbblockreference while traversing through an oddbblocktablerecord) you have to recursively keep track of these two colors unless this nested block reference itself is colorbyblock or colorbylayer.
last edited by hansverhoef; 18th november 2004 at 06:54 amfff">.
quote:
originally posted by rareba
short colorhope=line->colorindex();
use odcmcolor color = pe->color() instead and then parse it as your first post.
- if contain aci, just get colorindex.
- if rgb, lookup aci
- if "by layer", use layer color of block insertion entity
- if "by block", get color of block insertion entity & and parse it like this too.
best regards,
ivan obraztsov
"use odcmcolor color = pe->color() instead and then parse it as your first post.
- if contain aci, just get colorindex.
- if rgb, lookup aci
- if "by layer", use layer color of block insertion entity
- if "by block", get color of block insertion entity & and parse it like this too."
i think work fine but...
how can i obtain "layer color of block insertion entity" and "color of block insertion entity "?
what is the equivalent of "insert"?
in old library was "ad_ent_insert"
quote:
originally posted by rareba
i think work fine but...
how can i obtain "layer color of block insertion entity" and "color of block insertion entity "?
in your example:
"layer color of block insertion entity" - player->colorindex()
"color of block insertion entity " - pent->color().
best regards,
ivan obraztsov
yes but when i insert the block...
i don't konow insert the block. i use sample "odreadex" and there isn't insert. how can insert the block?
the equivalent of insert is oddbblockreference. i think there is an example for working with this type of entity.
best regards
chudomir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】error while including dbpolyline.h yang686526 DirectDWG 0 2009-05-05 09:49 AM
【转帖】determine oddbentity type yang686526 DirectDWG 0 2009-05-04 07:22 PM
【转帖】can i draw a custom object behind oddbentity yang686526 DirectDWG 0 2009-05-04 05:19 PM
【转帖】associate data to oddbentity yang686526 DirectDWG 0 2009-05-04 04:21 PM


所有的时间均为北京时间。 现在的时间是 05:27 PM.


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