高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】redefine the dimension block referenced by dimension entity
redefine the dimension block referenced by dimension entity
redefine the dimension block referenced by dimension entity
what is the correct procedure to redefine an existing dimension block after it was created by the function recomputedimblock()? the dimension was drew in my program is expressed in my own class,when save the file in dwg,i set parameters to form oddbdimension and call recomputedimblock(),the dimension block created by recomputedimblock() is not exactly same as i drew,for example ,the length of extension line,the position of the dimension text... so i transform the dimension in my own class to new set of oddbentity and want to redefine the created dimension block.i have iterated the dimension block record and make all entities to erase mode and then append my new set of entities, but i find there is no change,the dimension block is still the original one created by recomputedimblock().what should i do? thanks a lot.
the sample is:
odrxmoduleptr pmoudle=:drxdynamiclinker()->loadmodule("recomputedimblock.drx");
oddbblocktablerecordptr bbtr;
oddbrotateddimensionptr pdimension = oddbrotateddimension::createobject();
pdimension->setdatabasedefaults(pdb);
oddbobjectid dimensionid = bbtr->appendoddbentity(pdimension);
pdimension->setdatabasedefaults(pdb);
pdimension->setxline1point(startpoint);
pdimension->setxline2point(endpoint);
pdimension->setdimlinepoint(dimlinept);
pdimension->usedefaulttextposition();
pdimension->recomputedimblock();
oddbobjectid blockid=pdimension->dimblockid();
oddbblocktablerecordptr pbtr=blockid.openobject(oddb::kforwrite);
oddbobjectiteratorptr pentiter = pbtr->newiterator();
for (pentiter->start(); !pentiter->done(); pentiter->step())
{
oddbentityptr pentity=pentiter->entity(oddb::kforwrite);
pentity->erase();
}
odgepoint3d ptstart,ptend;
oddbmtextptr pmtext = oddbmtext::createobject();
oddblineptr pline1 = oddbline::createobject();
...
pline1->setstartpoint(ptstart); //start point of the first extension line
pline1->setendpoint(ptend); //end point of the first extension line
pbtr->appendoddbentity(pline1);
...
pbtr->appendoddbentity(pmtext); //dimension text
...
hello,
recompute block is run while dimension is closed.your changes are replaced. so you need use
odrxmoduleptr pmoudle=:drxdynamiclinker()->loadmodule("dummyrecomputedimblock.drx");
instead of
odrxmoduleptr pmoudle=:drxdynamiclinker()->loadmodule("recomputedimblock.drx");
in this case pdimension->dimblockid(); returns you empty block so you needn't erase it.
note dimension block is recomputed by acad in case any dimension property is changed.
best regards,
sergey z.
thanks a lot.but i don't have the module of "dummyrecomputedimblock.drx",where can i obtain it?
btw,recomputedimblock() of dummyrecomputedimblock.drx seems does nothing but return, that means it will not create the dimension block,then how can i get the dimension block referenced by the oddbdimension entity?
1. if recomputedimblock creates a block with representation you don't like than most probably it means that you set some properties of dimension style (or their overrides on dimension entity) incorrectly. i mean setdimxxx() functions.
if you replace the block with your representation then after opening the file in autocad and changing anything (say color) in dimension the block will be regenerated by autocad according to properties of dimension and dimension style.
if dwgdirect and autocad generate different blocks for the same dimension than it's dd bug and it should be fixed in dd.
2. in extensions folder where are recomputedimblock and dummyrecomputedimblock. these 2 projects build drx with the same name.
in case of using dummyrecomputedimblock you can create block manualy with name *d and set it to dimension using oddbdimension::setdimblockid().
sergey slezkin
|