高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】dimension style incorrect behavior
dimension style incorrect behavior
dimension style incorrect behavior
hi,
i have noticed a strange behavior connected to the dimension styles.
i have a drawing with one dimension in it. if i change the standard dim style(eg. changing arrow types to circles) and call "regen" after that, everything seems to be ok. the arrows are changed. what i'm expecting is all the next created dimensions to have circles for arrow types. but if i create a new one, the arrows are not circles - it seems the newest settings for the standard dim style are not considered at creation. is this is a dd bug? is there a way to create dims according to the latest settings in the dim style?
here is a sample source code used in odamfcapp(ver. 2.2.0) to prove the strange behavior
code:
oddbblocktablerecordptr pblock = m_pdb->getactivelayoutbtrid().safeopenobject(oddb::kforwrite);
{
int i = 0;
odstring snames;
for (oddbobjectiteratorptr piter = pblock->newiterator(); !piter->done(); piter->step(), i++ )
{
oddbrotateddimensionptr pdim = piter->entity()->objectid().safeopenobject(oddb::kforwrite);
oddbobjectid pstandarddimstyleid = m_pdb->getdimstylestandardid();
oddbdimstyletablerecordptr pstandarddimstyleptr = pstandarddimstyleid.safeopenobject(oddb::kforwrite);
pstandarddimstyleptr->setdimblk(dd_t("_dot"));
}
//create a new dim
odgepoint3d pt1start(500,1000,0), pt1end(700,1000,0);
oddbblocktablerecordptr pmodel = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
{
oddbrotateddimensionptr ptemp1 = oddbrotateddimension::createobject();
ptemp1->setxline1point(pt1start);
ptemp1->setxline2point(pt1end);
ptemp1->setdimlinepoint(odgepoint3d(500,1050,0));
pmodel->appendoddbentity(ptemp1);
}
m_pviewer->redrawwindow();
}
thanks in advance,
nino
your code does not set dimension style to newly created dimension.
besides current database dimension style (dimstyle variable) database dim* variables may contain overrides.
call pdim->setdatabasedefaults().
this function will set current dimension style and dim* overrrides (if any).
sergey slezkin
hi, sergey.
thanks for the attention. i tried to call setdatabasedefaults() but the newly created dimension is still different.
that's what i am trying:
code:
odgepoint3d pt1start(5,5,0), pt1end(7,5,0);
oddbblocktablerecordptr pmodel = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
{
oddbrotateddimensionptr pdim1 = oddbrotateddimension::createobject();
pdim1->setxline1point(pt1start);
pdim1->setxline2point(pt1end);
pdim1->setdimlinepoint(odgepoint3d(5,5.5,0));
pdim1->setdatabasedefaults(m_pdb);
pmodel->appendoddbentity(pdim1);
}
//change the standard dimstyle
oddbobjectid pstandarddimstyleid = m_pdb->getdimstylestandardid();
oddbdimstyletablerecordptr pstandarddimstyleptr = pstandarddimstyleid.safeopenobject(oddb::kforwrite);
pstandarddimstyleptr->setdimblk(dd_t("_dot"));
//create a new dim
odgepoint3d pt2start(5,10,0), pt2end(7,10,0);
{
oddbrotateddimensionptr pdim2 = oddbrotateddimension::createobject();
pdim2->setxline1point(pt2start);
pdim2->setxline2point(pt2end);
pdim2->setdimlinepoint(odgepoint3d(5,10.5,0));
pdim2->setdatabasedefaults(m_pdb);
pmodel->appendoddbentity(pdim2);
}
m_pviewer->redrawwindow();
how can i set dimension style to the newly created dims?
regards,
nino
you can set the dimstyle using pdimension->setdimensionstyle().
why you have the described results:
database stores a number of dimension variables: the default dimension style id and all values of dim* variables. if some dim* variables stored in database differ from corresponding values stored in current dimension style values of these variables are added to newly created dimension as overrides (they are stored in xdata).
after you changed dimblk in standard dimstyle the value of dimblk stored in database was unchanged. it differs from dimblk in current style and is added as dimblk override to newly created dimensions.
after changing dimblk in current dimstyle you can change it in database defaults too:
code:
oddbdimstyletablerecordptr pstandarddimstyleptr = pstandarddimstyleid.safeopenobject(oddb::kforwrite);
pstandarddimstyleptr->setdimblk(dd_t("_dot"));
pdb->setdimblk(pstandarddimstyleptr->dimblk());
after that new dimensions will be created with dot arrows.
sergey slezkin
hi, sergey.
it works now. thanks for the detailed explanation.
regards,
nino
|