![]() |
【转帖】invalid extents returned for dxf
invalid extents returned for dxf.
invalid extents returned for dxf. using the attached dxf drawing and version 1.13, the following code : code: // get the drawing extents for the active view. odgsview* pview = pdevice->viewat(0); bool bvalidextents = odabstractviewpeptr(pview)->zoomextents(pview); odgeboundblock3d boundblock; bvalidextents = odabstractviewpeptr(pview)->viewextents(pview, boundblock); double extsx = boundblock.maxpoint().x - boundblock.minpoint().x; double extsy = boundblock.maxpoint().y - boundblock.minpoint().y; returns incorrect extents of zero for both x and y, while the old opendwg toolkit\viewkit returned correct extents. the code works fine of all dwg and most dxf files. how can i get the correct extents of this drawing? regards, sijmen. attached files this is a bug in 1.13--we will get it fixed in the next maintenance release. thank you for reporting this. hi, it's not a bug actually... but anyway it can't be fixed in 1.13. in 1.13 odgsview object "knows" nothing about paperspace, it abstracted away from paperspace, modelspace and db itself, and extents of drawables in gs view in attached file is truly - empty. we added a workaround that will be illustrated in maintenance release of dd in odamfsapp example. the idea -- is to check extents returned by odabstractviewpe::viewextents() and to choose something reasonable if extents is empty. in this particular case - acad zooms to summary extents of all model view viewport entities in paper space (obtained via oddbviewport::getgeomextents()). there will be an implementation for oddblayout::getgeomextents() which calculates it. hi, i'm still having problems getting the extents on some dxf drawings. given the following code, how can i use oddbviewport::getgeomextents() or oddblayout::getgeomextents() to calculate the drawing extents. please take into consideration that i would like to be zoomed in so that i see the complete drawing at maximum size. code: oddbdatabaseptr pdb; pdb = m_myservices.readfile(szinfilename); if (!pdb.isnull()) { // create the vectorization context. odgicontextfordbdatabaseptr pdwgcontext = odgicontextfordbdatabase::createobject(); // set the database to be vectorized. pdwgcontext->setdatabase(pdb); // create the custom rendering device. odgsdeviceptr pdevice = cdwgvectorizedevice::createobject(); // cast the device to a cdwgvectorizedevice smart pointer. odsmartptr<cdwgvectorizedevice> pdwgvectorizedevice; pdwgvectorizedevice = static_cast<odsmartptr<cdwgvectorizedevice> >(pdevice); // prepare the device to render the active layout in this database. pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, pdwgcontext); // get the drawing extents for the active view. odgsview* pview = pdevice->viewat(0); bool bvalidextents = odabstractviewpeptr(pview)->zoomextents(pview); odgeboundblock3d boundblock; bvalidextents = odabstractviewpeptr(pview)->viewextents(pview, boundblock); double extsx = 0.0, extsy = 0.0; if (bvalidextents) { extsx = boundblock.maxpoint().x - boundblock.minpoint().x; extsy = boundblock.maxpoint().y - boundblock.minpoint().y; } else { // some dxf drawings don't return valid extents. // how can i get them. } } sijmen. hi, acad zooms to limmin-limmax box if there are no entities in model space and plimmin-plimmax -- in paper space (oddblayout::getgeomextents() will always return valid world extents for layout since v1.13.2. so it will look like: code: ... // v1.13- else { // some dxf drawings don't return valid extents. odgepoint3d min, max; if(pdb->gettilemode()) { (odgepoint2d&)min = pdb->getlimmin(); (odgepoint2d&)max = pdb->getlimmmax(); } else { (odgepoint2d&)min = pdb->getplimmin(); (odgepoint2d&)max = pdb->getplimmmax(); } min.transformby(pview->viewingmatrix()); // eye extents max.transformby(pview->viewingmatrix()); // eye extents extsx = max.x - min.x; extsy = max.y - min.y; } ... // v1.13.2+ else { // some dxf drawings don't return valid extents. oddblayoutptr playout = pdb->currentlayoutid().safeopenobject(); odgeextents3d ext; playout->getgeomextents(wext); // world extents ext.transformby(pview->viewingmatrix()); // eye extents extsx = ext.maxpoint().x - ext.minpoint().x; extsy = ext.maxpoint().y - ext.minpoint().y; } |
所有的时间均为北京时间。 现在的时间是 06:06 PM. |