高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】regression with dd 2.05.01
regression with dd 2.05.01
regression with dd 2.05.01
hi,
this code doesn't works correctly with the new version dd 2.05.01.
code:
oddbobjectid oddbobjid;
oddbobjid = oddbsymutil::gettextstyleid(_t("style4"), getdatabase());
oddbtextptr textptr = oddbtext::createobject();
textptr->setposition(odgepoint3d(10, 10, 0));
textptr->settextstring(_t("hello world"));
textptr->settextstyle(oddbobjid);
textptr->setheight(1.5);
oddbblocktablerecordptr btrptr = getdatabase()->getactivelayoutbtrid().openobject(oddb::kforwrite);
btrptr->appendoddbentity(textptr);
textptr->setdatabasedefaults(getdatabase());in older version dd 2.03.00, the height of the text was 1.5 and the textstyle was style4, in the new version his height is 2.5 and his style is standard.
it's due to the call of textptr->setdatabasedefaults(getdatabase()), why did you change this behavior ?
attached files
here is the dwgdirectc++ doc:
quote:
void oddbentity::setdatabasedefaults(oddbdatabase* pdb = 0,bool dosubents = false)
applies the default properties of the specified database to this entity.
parameters
pdb (i) pointer to the database whose default values are to be used.
dosubents (i) set to true if subentities should be processed
remarks
if pdb is null, the database containing this entity is used.
the following properties are set
color
layer
linetype
linetype scale
lineweight
plotstyle
visibility
i can't see textstyle in the properties set !
regards.
setdatabasedefaults should be called immediately after object creation.
if text style was not set in earlier versions, then it is a fixed bug.
vladimir
these properties are listed for oddbentity::setdatabasedefaults(). this is virtual function which can be overridden in derived classes to set more values.
previously oddbtext::setdatabasedefaults() was not implemented (it was a bug).
setdatabasedefaults() must be always called before setting properties explicitely. else it may reset them like in your case.
sergey slezkin
quote:
previously oddbtext::setdatabasedefaults() was not implemented (it was a bug).
good job !
but now we have an "incompatibility" with autocad.
look at this code in objectarx, setdatabasedefault doesn't reset properties after setting them.
code:
acdbdatabase *pdb = acdbcurdwg();
acdbobjectid objid;
const tchar *pstyle = _t("style4");
acad::errorstatus errorstatus;
acdbtextstyletable *ptextstyletable;
errorstatus = pdb->gettextstyletable(ptextstyletable, acdb::kforread);
if (errorstatus == acad::eok)
{
errorstatus = ptextstyletable->getat(pstyle, objid);
ptextstyletable->close();
}
acdbtext *ptext = new acdbtext(acgepoint3d(0,0,0), _t("hello world"), objid, 1.5);
acdbblocktable *pblocktable;
acdbblocktablerecord *pblocktablerecord;
pblocktable = null;
pblocktablerecord = null;
pdb->getblocktable(pblocktable, acdb::kforread);
if (pblocktable)
{
acad::errorstatus ret;
ret = pblocktable->getat(acdb_model_space, pblocktablerecord, acdb::kforwrite);
pblocktable->close();
}
errorstatus = pblocktablerecord->appendacdbentity(ptext);
ptext->setdatabasedefaults(ptext->database());
double height = ptext->height(); // return 1.5 not 2.5 (height of current textstyle)
ptext->close();
acdbline *pacdbline = new acdbline(acgepoint3d(0,0,0), acgepoint3d(10,10,0));
errorstatus = pblocktablerecord->appendacdbentity(pacdbline);
pacdbline->setlayer(_t("layer1"));
pacdbline->setdatabasedefaults(pacdbline->database());
tchar *playername = null;
playername = pacdbline->layer(); // return 'layer1' not '0' ('0' is current layer)
delete [] playername;
pacdbline->close();
|