getgeomextents not working
getgeomextents not working
i am trying to get the true extents of the geometry in the model and paper space views. i can go into autocad and figure out the true extents, but the value returned by getgeomextents is not the same as the true extents. this is true even if i do a zoomextents first.
i would have thought this was a fairly simple and common operation.
i am using:
oddbobjectid msid = pdb->getmodelspaceid();
oddbblocktablerecordptr pblock = msid.safeopenobject();
odgeextents3d extents;
pblock->getgeomextents(extents);
am i doing something wrong?
hi,
dd (just like autocad) uses different code for calculating extents in getgeomextents() and in active view when you choose "zoom extents", it's because of that second extents depend on view and viewport settings.
to calculate view extents you should use:
code:
odrxobjectptr pview = ...; // get view object
// pview should be either oddbviewporttablerecord or oddbviewport or corresponding odgsview.
odabstractviewpeptr pvppe(pview);
odgeboundblock3d bbox;
bool bbboxvalid = pvppe->viewextents(pview, bbox); // ext in eye cs
if(bbboxvalid )
{
// extents not empty
bbox.trasformby(pvppe->eyetoworld(pview)); // wcs (either paper or model)
}
else
{
// empty
}
see cdwgviewer:

nviewzoomextents() in odamfcapp for more info.