几何尺寸与公差论坛------致力于产品几何量公差标准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, 06:18 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】named view extents

named view extents
named view extents
i am trying to get the extents of a named view but i must be doing something wrong. the extents value i get (in "boundblock" below) is 0.,0. for both max and min.
i am using the following code:
code:
oddbobjectid tablid = pdb->getviewtableid();
oddbviewtableptr tablptr = tablid.safeopenobject();
oddbsymboltableiteratorptr iter = tablptr->newiterator();
int i = 0;
for (iter->start(); !iter->done(); iter->step() )
{
oddbviewtablerecordptr pnamedview = iter->getrecordid().openobject();
if (stricmp(pnamedview->getname(), viewname) == 0)
{
cout << "view: "<< viewname << " ** selected **" << endl;
odabstractviewpeptr pnamedviewpe(pnamedview);
oddbobjectid ltid = oddbblocktablerecordptr(pdb->getactivelayoutbtrid().safeopenobject())->getlayoutid();
oddblayoutptr playout = ltid.safeopenobject();
oddbobjectid overallvpid = playout->overallvportid(); // for paper space
oddbviewporttableptr pvptabl = pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptabl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject();
pnamedviewpe->setview(prec, pnamedview);
odgeboundblock3d boundblock;
pnamedviewpe->viewextents(pnamedview, boundblock);
}
}
}
named view extents
i still have not been able to figure out the extents of a named view. i must be missing something obvious. i could really use some help. thanks.
hi,
in current implememntation oddbviewtablerecord:dabstractviewpe::viewextents () does nothing. but as you copy view to a viewport you may call last one's viewextents():
code:
oddbobjectid tablid = pdb->getviewtableid();
oddbviewtableptr tablptr = tablid.safeopenobject();
oddbsymboltableiteratorptr iter = tablptr->newiterator();
int i = 0;
for (iter->start(); !iter->done(); iter->step() )
{
oddbviewtablerecordptr pnamedview = iter->getrecordid().openobject();
if (pnamedview->getname()==viewname)
{
cout << "view: "<< viewname << " ** selected **" << endl;
oddbobjectid ltid = oddbblocktablerecordptr(pdb->getactivelayoutbtrid().safeopenobject())->getlayoutid();
oddblayoutptr playout = ltid.safeopenobject();
oddbobjectid overallvpid = playout->overallvportid(); // for paper space

oddbviewporttableptr pvptabl = pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptabl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject(oddb::kforwrite);
odabstractviewpeptr pvppe(prec);
pvppe->setview(prec, pnamedview);
odgeboundblock3d boundblock;
pvppe->viewextents(prec, boundblock);
}
}
}

that does not seem to work for me. i get the height to width ratio of the full modelspace view, not that of a given named view. for instance, in the attached file i get a height to width ratio for the named view "frt" of about 1:2 (97 to 190) while it should be about 2:3 (about 12 high to 17 wide).
it appears that setview is being ignored for getting the extents.
here is the code i am currenlty using:
oddbviewporttableptr pvptabl = pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptabl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject(oddb::kforwrite);
odabstractviewpeptr pvppe(prec);
pvppe->setview(prec, pnamedview);
odgeboundblock3d boundblock;
bool bvalid = pvppe->viewextents(prec, boundblock);
odgepoint3d bbmin = boundblock.minpoint ();
odgepoint3d bbmax = boundblock.maxpoint ();
}
attached files (52.5 kb, 2 views)

hi,
>>it appears that setview is being ignored for getting the extents.
viewextents() returns extents of space block viewed in giving view in eye coordinates of giving view. the result depends on view target, direction and up vector. but 1st of all extents depend on geometry drawn in this view.
what results do you want to achieve ?
last edited by dmitry a. novikov; 26th july 2005 at 11:25 pmfff">.
quote:
originally posted by dmitry a. novikov
hi,
>>it appears that setview is being ignored for getting the extents.
viewextents() returns extents of space block viewed in giving view in eye coordinates of giving view. the result depends on view target, direction and up vector. but 1st of all extents depend on geometry drawn in this view.
what results do you want to achieve ?
i need to know the coordinates (in whatever coordinate system i can get them in) of the limits of the named view. i need to know the lower left corner of the named view is at (x1,y1) and the upper right corner of the named view is at (x2,y2). i need to clip the geometry to the limits of the named view, but i can't do that without knowing those limits. i do not need to know the extents of the geometry within the view, but rather the size of the view itself (including the geometry and any white space that is in the view). that is obviously available somewhere since it will center the display around the named view. i just need to convert the drawing and not have anything that is outside the named view displayed.
hi,
in common case view defines a frustum (perspective case) or prism (parallel case).
here is how to calculate view rectangle (profile of view frustum or prism) in wcs:
code:
odgepoint3d target = pvppe->target(pview);
double fw2 = pvppe->fieldwidth(pview) / 2.;
double fh2 = pvppe->fieldheight(pview) / 2.;
odgevector3d z = pvppe->direction(pview);
odgevector3d y = pvppe->upvector(pview);
odgevector3d x = y.crossproduct(z);
odgepoint3d lowerleft = target - x * fw2 - y * fh2;
odgepoint3d upperleft = target - x * fw2 + y * fh2;
odgepoint3d upperright = target + x * fw2 + y * fh2;
odgepoint3d lowerright = target + x * fw2 - y * fh2;
in eye cs it's always planar and calculated as following:
code:
odgepoint3d lowerlefteye(-fw2, -fh2, 0.);
odgepoint3d upperrighteye(fw2, fh2, 0.);
// where:
// lowerlefteye == pvppe->worldtoeye(pview) * lowerleft;
// upperrighteye == pvppe->worldtoeye(pview) * upperright;
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】invalid extents returned for dxf yang686526 DirectDWG 0 2009-05-06 04:03 PM
【转帖】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
【转帖】drawing view placements yang686526 SolidWorks二次开发 0 2009-04-13 10:35 AM
【转帖】drawing view extents ... got huge yang686526 SolidWorks二次开发 0 2009-04-13 10:34 AM


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


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