高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】a dimension error
a dimension error
a dimension error
the error occurs when i export a line and a dimension. opening the attachment file drawing10.dwg, the left is the correct dimension(it's a named block,and is inserted into the drawing). the right is the line and the wrong dimension. what does cause this error? now the dwgdirect library i am using is 1.10 update 1.
attached files
if i understood you correctly you create a dimension which should look like the picture at the left but it looks like the dimension at the right.
what code do you use to create it?
sergey slezkin
this is my code
yes, you are right!
//create a rotate dimension
oddbrotateddimensionptr protdim = ddbrotateddimension::createobject( );
//create a block to contain the visual representation(dimension lines and so on, return this block by its id)
oddbobjectid dimblockid;
dimblockid.setnull( );
//create block
char blkname[] = "*d"; // must be "*d"
oddbblocktablerecordptr ptmpblk = oddbblocktablerecord::createobject();
ptmpblk->setname( odstring( blkname ));
oddbblocktableptr pblocks = pdb->getblocktableid().safeopenobject( oddb::kforwrite );
//add this block to block table
pblocks->add( ptmpblk );
//write the block interior (entities to represent dimensions visually)
// first dimension line
oddblineptr pline = oddbline::createobject( );
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// second dimension line
oddblineptr pline = oddbline::createobject( );
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// extension line 1
oddblineptr pline = oddbline::createobject( );
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// extension line 2
if( createlineentity(pwrapper,pline,&dimclrd, &dimlinewidth) )
{
if( writelineentity(pline,startpt, endpt) )
ptmpblk->appendoddbentity( pline );
}
// add dimension text(oddbmtext) into the ptmpblk block
...........
ptmpblk->appendoddbentity(pmtext);
// add leader into the ptmpblk block
.................
ptmpblk->appendoddbentity(ppolyline);
dimblockid = ptmpblk->objectid( );
assert( !dimblockid.isnull() );
protdim->setdimblockid( dimblockid ); //set dim block id
//set dimension
protdim->setxline1point( odgepoint3d( planept0[0],planept0[1],planept0[2] ));
protdim->setxline2point( odgepoint3d( planept1[0],planept1[1],planept1[2] ));
protdim->setdimlinepoint( odgepoint3d( dimlinest[0],dimlinest[1],dimlinest[2] ));
protdim->setrotation( ...);
protdim->settextrotation(...);
protdim->setdimensiontext( textstr.getbuffer(textstr.getlength()+1) );
// set initial location of text .
protdim->settextposition( odgepoint3d(textpt[0],textpt[1],textpt[2]) );
protdim->settextattachment(oddbmtext::kmiddlecenter );
//add this dimension to the modelspace block
pmodelspaceblock->appendoddbentity( protdim );
the export is right in other case, e.g. the dimension line is parallel with the line. but in this case it is error.
quote:
originally posted by sergey slezkin
if i understood you correctly you create a dimension which should look like the picture at the left but it looks like the dimension at the right.
what code do you use to create it?
after a dimension is created or modified dd recomputes dimension block based on dimension properties and style.
the situation you have may happen if
1. coordinates you set to dimension realy specify a dimension you see as result.
2. dd incorrectly recomputes dimension block.
to determine the reason i need actual values you set to dimension.
it's possible to avoid recomputing of dimension block by dd if you call pdim->recordgraphicsmodified(false) after you set all properties to dimension.
please made the following experiment:
insert protdim->recordgraphicsmodified(false) at the end of your code.
save the file.
open the file with autocad. you see your block.
select the dimension and alter something in its properties (color for example). the dimension block gets recomputed by autocad.
if it's appearence is the same (except color) - dd was incorrectly recomputing the block.
if it's appearence changes - coordinates you set to dimension do not match block you generated.
sergey slezkin
the test result
thanks for your help!
following as you told me, i made this experiment.here is the result: after adding this code protdim->recordgraphicsmodified(false), exporting a case like the first post to autocad, the dimension looked like the dimension block. in autocad, modifing the dimension color, the block was not
modified by autocad. they looked like the same except the color.
quote:
originally posted by sergey slezkin
after a dimension is created or modified dd recomputes dimension block based on dimension properties and style.
the situation you have may happen if
1. coordinates you set to dimension realy specify a dimension you see as result.
2. dd incorrectly recomputes dimension block.
to determine the reason i need actual values you set to dimension.
it's possible to avoid recomputing of dimension block by dd if you call pdim->recordgraphicsmodified(false) after you set all properties to dimension.
please made the following experiment:
insert protdim->recordgraphicsmodified(false) at the end of your code.
save the file.
open the file with autocad. you see your block.
select the dimension and alter something in its properties (color for example). the dimension block gets recomputed by autocad.
if it's appearence is the same (except color) - dd was incorrectly recomputing the block.
if it's appearence changes - coordinates you set to dimension do not match block you generated.
so it seems that dd computes dimension block incorrectly. but i failed to reproduce it. probably it depends on specific coordinates and properties. it can be verified if you load the file you created in odamfcapp and invoke edit/recompute dimension blocks. if dimension appearence changes as a result of this operation please send me the file or post it to the forum.
sergey slezkin
i will test
i will test as you told me, and i will post the result as soon as possible.
quote:
originally posted by sergey slezkin
so it seems that dd computes dimension block incorrectly. but i failed to reproduce it. probably it depends on specific coordinates and properties. it can be verified if you load the file you created in odamfcapp and invoke edit/recompute dimension blocks. if dimension appearence changes as a result of this operation please send me the file or post it to the forum.
the right and error file
if you open the right.dwg file in odamfcapp, in blocktable section, you will see a block named "d", it is the right dimension block.when exporting this file, i called protdim->recordgraphicsmodified(false) function to prevent dwgdirect recompute this dimension block. and in model_space block, you will see a rotae dimension entity, this dimension entity refers to the block "d".
if you open the error.dwg file, you will see a block named "d" and a block named "*d5", the block "d" is the right block. i didn't create the block "*d5" in my code. maybe this block is created by dwgdirect by recomputing the right block "d". add the rotate dimension refers to the error block "*d5" but not to the right block "d". when exporting this file, i didn't call function recordgraphicsmodified(false) to prevent dwgdirect to recompute the right dimension block.the dwgdirect recomputes the block "d" incorrectly.
quote:
originally posted by enigma
i will test as you told me, and i will post the result as soon as possible.
attached files (11.8 kb, 3 views)
(12.5 kb, 3 views)
the dimension was created incorrectly.
open right.dwg with autocad. save it to dxf.
select the dimension and change its linetype for example to force revomputing of block. set it back to bylayer.
save the file to dxf.
comparing 2 files shows that autocad altered dimension line definition point (group code 10) to heal the entity.
dd treats such kind of incorrect data a bit differently. we'll fix it.
btw, the dimension entity has null dimstyle. both autocad and dd can live with it but it's better to set it to some value.
sergey slezkin
my dimension is wrong?
my "right" dimension is wrong? what's wrong cause autocad alteres dimension line definition point (group code 10) ? can you tell me in detail where is wrong in my code in the previous post and how can fix it?
quote:
originally posted by sergey slezkin
the dimension was created incorrectly.
open right.dwg with autocad. save it to dxf.
select the dimension and change its linetype for example to force revomputing of block. set it back to bylayer.
save the file to dxf.
comparing 2 files shows that autocad altered dimension line definition point (group code 10) to heal the entity.
dd treats such kind of incorrect data a bit differently. we'll fix it.
btw, the dimension entity has null dimstyle. both autocad and dd can live with it but it's better to set it to some value.
sorry, i was wrong saying that your dimension is created incorrectly. theoretically it's ok but:
your dimension has dimension line point set on extension line 1. autocad sets it on extension line 2. during block recomputing autocad updates it and sets it to the point on extension line 2 (group code 10 changes).
dd has a bug which has effect in your case (dim line point on extension line 1).
untill we fix it possible work around is to set dim line point on extension line 2 as autocad does.
sergey slezkin
|