几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 04:03 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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;
}
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】getting the extents yang686526 DirectDWG 0 2009-05-05 11:33 AM
【转帖】get extents of drawing yang686526 DirectDWG 0 2009-05-05 11:15 AM
【转帖】dwg extension in world coordinates yang686526 DirectDWG 0 2009-05-05 08:01 AM
【转帖】drawing extents changes after adding te yang686526 DirectDWG 0 2009-05-04 08:08 PM
【转帖】calculating extents draw yang686526 DirectDWG 0 2009-05-04 05:17 PM


所有的时间均为北京时间。 现在的时间是 01:16 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多