rotated dimension and dimassoc problem
rotated dimension and dimassoc problem
hallo
i have a problem with rotated dimension and the osnappointrefs. i think the creation of the dimension / extensiondictionary and osnappointrefs are correct.
when i load the dwg file in autocad all is ok. but when i move a point (point is associative in the dimension) of the polyline then the dimension is corrupt.
what is wrong ????
code :
....
oddbrotateddimensionptr pad = oddbrotateddimension::createobject();
oddbobjectid pobjectid = pblock->appendoddbentity(pad);
pad->setdatabasedefaults(pdb);
pad->setxline1point(point1);
pad->setxline2point(point2);
pad->setdimlinepoint(position);
pad->setrotation(rotation);
pad->usedefaulttextposition();
pad->createextensiondictionary();
pad->setlayer(layerid, true);
....
oddbdictionaryptr dict = pad->extensiondictionary().safeopenobject(oddb::kforwr ite);
oddbdimassocptr dimassoc = oddbdimassoc::createobject();
dimassoc->setdimension(pobjectid);
dimassoc->setrotateddimtype(oddbdimassoc::kparallel);
oddbobjectid dimassid = dict->setat("acad_dimassoc", dimassoc);
oddbosnappointrefptr pointref;
int pointindex=oddbdimassoc::kfirstpoint;
// startpunkt
pointref = exportdimpointref(dimassid, dimassoc,
oddb::kosmodestart,
(oddbdimassoc::associativity)pointindex++,
apu);
// endpunkt
pointref = exportdimpointref(dimassid, dimassoc,
oddb::kosmodeend,
(oddbdimassoc::associativity)pointindex++,
epu);
// setting reactors
if ( !pointref.isnull() ) {
oddbobjectid pobjectid = (const oddbobjectid&) apu->pobjurs;
oddb2dpolylineptr p2dpoly = pobjectid.safeopenobject(oddb::kforwrite);
pad->addpersistentreactor(dimassid);
p2dpoly->addpersistentreactor(dimassid);
pad->recomputedimblock(true);
}
oddbosnappointrefptr dgnexport::exportdimpointref (const oddbobjectid &dimassid,
oddbdimassocptr dimassoc,
oddb:

snapmode snapmode,
oddbdimassoc::associativity pointindex,
punk tpu)
{
oddbosnappointrefptr pointref;
// assoziate vermassung erzeugen
if ( tpu && tpu->pobjurs ) {
oddbobjectid pobjectid = (const oddbobjectid&) tpu->pobjurs;
oddbobjectptr pobject = pobjectid.safeopenobject();
oduint32 isubindex = tpu->tmz;
if ( !pobject.isnull() ) {
if (pobject->iskindof(oddb2dpolyline::desc()) ) {
oddbobjectid pvertexid = (const oddbobjectid&) tpu->dum;
oddb2dvertexptr pvertex = pvertexid.safeopenobject();
//oddb2dvertexptr pvertex = pvertexid.safeopenobject(oddb::kforwrite);
//pvertex->addpersistentreactor(dimassid);
if ( !pvertex.isnull() ) {
// oddb2dpolylineptr p2dpoly = pobjectid.safeopenobject(oddb::kforwrite);
pointref = oddbosnappointref::createobject();
pointref->osnappoint() = pvertex->position();
// if (pointindex == oddbdimassoc::kfirstpoint) {
// p2dpoly->addpersistentreactor(dimassid);
// }
}
if ( !pointref.isnull() ) {
pointref->setosnapmode(snapmode);
if ( snapmode == oddb::kosmodeend ) {
pointref->setnearosnap(1.0);
} else {
pointref->setnearosnap(0.0);
}
pointref->mainentity().objectids().append(pobjectid);
pointref->mainentity().subentid().settype(oddb::kedgesubent type);
pointref->mainentity().subentid().setindex(isubindex);
// dimassoc->setosnappointref((oddbdimassoc::associativity)poi ntindex++, pointref);
dimassoc->setosnappointref(pointindex, pointref);
}
}
}
return(pointref);
}
attached files
hello,
you need to add in your code ( method oddbosnappointrefptr dgnexport::exportdimpointref ) after line
pointref->mainentity().objectids().append(pobjectid);
this line
pointref->mainentity().objectids().append(pvertexid);
best regards,
sergey z.
hallo,
we have tested this in our code and this change only little bit. only the first point from
the "diagonal" dimension can be moved and the measurement is correct. by all other movements the dimension will become incorrect !!!! ????
attached files (25.3 kb, 1 views)
hello,
i found what you need
pointref->setosnaptype(oddb::kosmodeend); for second point for wrong situation. it defines start or end endge of polyline is used. or you may set other vertex without change osnap type.
unfortunately i can't help with rules which acad uses for creating associate and i don't know any reference.
best regards,
sergey z.
hallo,
we have solved the problem with the rotated dimension. but we have same trouble with the diameter dimension. when we change the circle in acad the dimension will be corrupt like
the rotated dimension. we have exported a new diameter dimension in acad and compared it with our export. but we do not understand the differences !!!
what is wrong !!!! ?????
with no example it is hard to code an export !!!!!
our code.
oddbobjectid dgnexport::exportdiametricdimension (oddbdatabase* pdb,
oddbblocktablerecord* pblock,
const oddbobjectid& layerid,
const oddbobjectid& dimstyleid,
const odgepoint3d& point1,
const odgepoint3d& point2,
const odgepoint3d& position,
double tx_height,
oddbmtext::attachmentpoint tx_attachment,
const odgepoint3d& tx_position,
double tx_rotation,
oduint16 tx_just,
oduint16 tx_dec,
elem tel,
punk mpu)
{
uwrd aielrgb[3];
swrd ielltyp, ielcolor;
oddbobjectid linetypeid;
oddbdiametricdimensionptr pad = oddbdiametricdimension::createobject();
oddbobjectid pobjectid = pblock->appendoddbentity(pad);
pad->setdatabasedefaults(pdb);
// vermassungs-stil setzen
pad->setdimensionstyle(dimstyleid);
pad->setchordpoint(point1);
pad->setfarchordpoint(point2);
// keine fuehrungslinie fuer masstext setzen
pad->setleaderlength(0.);
// pad->usedefaulttextposition();
pad->createextensiondictionary();
pad->setlayer(layerid, true);
// vm-texthoehe setzen
pad->setdimtxt(tx_height);
// vm-textausrichtung setzen
// pad->settextattachment(tx_attachment);
// vm-textposition setzen
// pad->settextposition(tx_position);
// vm-textwinkel setzen
// pad->settextrotation(tx_rotation);
// vm-text parallel zur masslinie
// pad->setdimtih(false);
// vm-textlage: 0=zentriert, 1=links, 2=rechts
pad->setdimjust(tx_just);
// vm-text: nachkommastellen
pad->setdimdec(tx_dec);
// element-linientyp holen und setzen
ielltyp = get_ellin(tel);
linetypeid = getlinetypid(ielltyp);
if ( !linetypeid.isnull() ) {
pad->setlinetype(linetypeid);
}
// element-linenbreite setzen
dreal relstartwidth = getstartwidth(tel, punull);
if ( relstartwidth > 0. ) {
oddb::lineweight lineweight = convertlinewidth_lineweight(relstartwidth);
pad->setlineweight(lineweight);
}
// element-farbe holen und setzen
ielcolor = getcolorrgb(tel, wel_frb, aielrgb);
if ( ielcolor == gut ) {
odcmcolor col;
col.setcolormethod(odcmentitycolor::kbycolor);
col.setrgb(aielrgb[0], aielrgb[1], aielrgb[2]);
pad->setcolor(col, true);
}
// assoziate vermassung erzeugen
if ( (mpu) &&
(mpu->pobjurs) ) {
oddbdictionaryptr dict = pad->extensiondictionary().safeopenobject(oddb::kforwr ite);
oddbdimassocptr dimassoc = oddbdimassoc::createobject();
dimassoc->setdimension(pobjectid);
dimassoc->setrotateddimtype(oddbdimassoc::kparallel);
oddbobjectid dimassid = dict->setat("acad_dimassoc", dimassoc);
oddbobjectid pobjectid = (const oddbobjectid&) mpu->pobjurs;
oddbcircleptr pcircle = pobjectid.safeopenobject(oddb::kforwrite);
oddbosnappointrefptr pointref = oddbosnappointref::createobject();
pointref->osnappoint() = pcircle->center();
pointref->setosnapmode(oddb::kosmodecen);
pointref->setnearosnap(0.0);
pointref->mainentity().objectids().append(pobjectid);
pointref->mainentity().subentid().settype(oddb::kedgesubent type);
dimassoc->setosnappointref(oddbdimassoc::kfirstpoint, pointref);
// setting reactors
pcircle->addpersistentreactor(dimassid);
pad->addpersistentreactor(dimassid);
}
return(pobjectid);
}
hello,
try to use
dimassoc->setosnappointref(oddbdimassoc::ksecondpoint, pointref);
instead of
dimassoc->setosnappointref(oddbdimassoc::kfirstpoint, pointref);
acad use second point for associativity with diametric and radial dimensions. i don't know why.
best regards,
sergey z.