高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】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
|