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

appendloop() exception question
appendloop() exception question
hi,
we're using dd 1.14.02. am appending a single database object as a loop to hatch. the object is a oddb2dpolyline.
consider the following vertices:
v1 = (1, 2)
v2 = (2, 2)
v3 = (1, 3)
v4 = (2, 3)
v5 = (2, 1)
when the polyline is made as {v1, v2, v1, v3, v4, v5, v1}, appendloop() throws invalid input exception.
initially i thought it was the problem with inner loop {v1, v2, v1} preceding the outer loop {v1, v3, v4, v5, v1} in the order. so i tried reversing. but polyline made as {v1, v5, v4, v3, v1, v2, v1} produces the same result.
when the polylne is made as {v2, v1, v3, v4, v5, v1, v2} it creates the hatch just fine.
can someone please advice.
incidently, it was working perfectly fine using old odt.
thanks,
varun

has anyone else encountered such problems. if so, i'd be very much interested in the workaround you developed to overcome this.
thanks,
varun
from objectarx help:
a loop must be simple, closed, and continuous, intersecting itself only at its endpoints. furthermore, its start point and end point must coincide. when defining the hatch boundary, the application must ensure that the loops and edges are well defined and structured. if the boundary contains two or more loops, they must be organized into a nested structure in which the external loop is constructed first, then followed by all its internal loops in nested order. if there is more than one external loop, repeat the process. autocad provides limited validation of the hatch boundary in order to maintain api efficiency and performance.
actually non-closed, self-intersecting etc. loops cause problems only with solid hatches.
solid hatch does not like (v1,v2,v1) part of your path.
sergey slezkin

hi,
can anyone suggest some pointers to good algorithms to ensure polylines are simple and non self intersecting. my app does not provide a rich toolkit for ensuring the strigent conditions laid down for hatch loops.
thanks,
varun
i am getting the same exception from appendloop(). the object array contains a single polyline with the following points:
dwgdirect exception: invalid input
polyline point=(17.01597613642, 3.03995167676, 0.00000000000)
polyline point=(17.01597613642, 14.59640955921, 0.00000000000)
polyline point=(24.72712509877, 3.03995167676, 0.00000000000)
polyline point=(17.01597613642, 3.03995167676, 0.00000000000)
the hatch is a solid hatch. the polyline forms a triangle and the first and last points are the same to at least 11 decimal places. i can't see how this input would be invalid based on the description posted earlier.
i am using dd version 2.0.3 with msvc++ 2003. this same code worked in dd version 1.13.2.
any ideas?
i downloaded and installed dd version 2.1.0, and this problem persists.
bcavebmg, your problem seems to be a different one from mine. does it work if you specifiy a different pattern than solid? there was some issue with tolerance as well regarding this, but i think it was fixed in 1.14.03 (sorry, i can't seem to find the relavent thread at this moment.)
btw, i got around the original problem by checking for duplicated edges, and if present adding the entity as a spline instead of a polyline (worked like a beauty! )
regards,
varun
can you post the code you are using to append loop?
vladimir
this is the gist of it:
code:
oddbobjectidarray aobjs;
// fill aobjs with ids for objects to be hatched. in the case where,
// i get an exception, it contains a single polyline as described above.
oddbhatchptr phatch = oddbhatch::createobject();
phatch->setpattern(oddbhatch::kpredefined, "solid");
phatch->setassociative(true);
phatch->sethatchstyle(oddbhatch::knormal);
phatch->setcolorindex(3);
phatch->appendloop(oddbhatch::kexternal, aobjs);as i mentioned before, this code worked with dd 1.13.2, but does not work with version 2.0.3 or 2.1.0.
i used the following test code, and could not reproduce the problem:
code:
void _hatchtest_func(odedcommandcontext* pcmdctx)
{
oddbcommandcontextptr pdbcmdctx(pcmdctx);
oddbdatabaseptr pdb = pdbcmdctx->database();
oddbobjectidarray aobjs;
oddbblocktablerecordptr ms = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
oddbpolylineptr poly = oddbpolyline::createobject();
poly->addvertexat(0,odgepoint2d(17.01597613642, 3.03995167676));
poly->addvertexat(1,odgepoint2d(17.01597613642, 14.59640955921));
poly->addvertexat(2,odgepoint2d(24.72712509877, 3.03995167676));
poly->addvertexat(3,odgepoint2d(17.01597613642, 3.03995167676));
aobjs.append(ms->appendoddbentity(poly));
// fill aobjs with ids for objects to be hatched. in the case where,
// i get an exception, it contains a single polyline as described above.
oddbhatchptr phatch = oddbhatch::createobject();
phatch->setpattern(oddbhatch::kpredefined, "solid");
phatch->setassociative(true);
phatch->sethatchstyle(oddbhatch::knormal);
phatch->setcolorindex(3);
phatch->appendloop(oddbhatch::kexternal, aobjs);
ms->appendoddbentity(phatch);
}what kind of polyline do you use?
vladimir
here is how i construct the polyline:
code:
oddbpolylineptr pacadpolyline = oddbpolyline::createobject();
pacadpolyline->minimizememory();
// "points" is a collection of point objects.
for (size_t i = 0; i < points.getcount(); i++)
{
point pt = points.getat(i);
pacadpolyline->addvertexat(pacadpolyline->numverts(), odgepoint2d(pt.x, pt.y));
}
pacadpolyline->setclosed(true);
pacadpolyline->setlayer(idlayer);
oddbobjectid idnewentity = pdwgblock->appendoddbentity(pacadpolyline);it is pretty straightforward. i tried removing the call to minimizememory(), but i still get the exception.
some more info...
i tried removing the call to pacadpolyline->setclosed(true), and now the exception has gone away. maybe the problem is related to that?
yes, it is a bug in dd appendloop code. it adds empty segment if polyline is closed and its start and end points are the same (redundantly closed polyline). then it checks edge data and complains on empty edge segment.
as a workaround you may check for such condition and open polylines while adding loops, or, if you create the polylines yourself - do not add last duplicated point if the polyline is intended to be closed.
the bug will be fixed in the next update.
vladimir
hello,
is it safe using a hatch entity, when appendloop() throws "invalid input" exception?
for example, at the begining i had treat this exception, then i call appendloop() once again for add an anohter loop.
best regards,
andrey.
yes, it is safe - hatch is modified only when all the checks are passed.
vladimir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】acis question yang686526 DirectDWG 0 2009-05-04 03:38 PM
【转帖】assembly drawing bom change question yang686526 American standards 0 2009-04-29 06:31 PM
【转帖】a quick question on total runou yang686526 American standards 0 2009-04-29 06:17 PM
【转帖】video card driver question yang686526 SolidWorks二次开发 0 2009-04-13 03:16 PM
【转帖】rap unhandled exception even yang686526 SolidWorks二次开发 0 2009-04-13 03:02 PM


所有的时间均为北京时间。 现在的时间是 02:34 PM.


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