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

setclosed does not work (as expected)
setclosed does not work (as expected)
hi
the setclosed method on a polyline does not really do that much. the method isclosed returns always (!!) true even if i call explicitely setclosed(false). it does not matter whether the polyline is really closed (last point = first point).
code:
oddbpolylineptr pentity = ...
...
pentity->setclosed(false);
bool bclosed = pentity->isclosed();
isn't that how setclosed and isclosed are supposed to work?!?
simon
this is obviously dd bug. thanks for reporting it.
sergey slezkin
are you sure your sample code is the same as in your application? we failed to reproduce the situation. oddbpolyline::setclosed() and isclosed() work fine for us. maybe your situation is a bit different. for example oddbcurve has implementation of isclosed() which checks start and end points. but the function is virtual and if you use pointer to polyline oddbpolyline::isclosed() should be called.
sergey slezkin
quote:
originally posted by sergey slezkin
are you sure your sample code is the same as in your application? we failed to reproduce the situation. oddbpolyline::setclosed() and isclosed() work fine for us. maybe your situation is a bit different. for example oddbcurve has implementation of isclosed() which checks start and end points. but the function is virtual and if you use pointer to polyline oddbpolyline::isclosed() should be called.
i use an oddbpolyline:
code:
oddbpolylineptr pentity = oddbpolyline::createobject();
does a call to addvertex change the value of isclosed()? i call setclosed(true) first and then i add vertices. if i remember correctly then it didn't even work when i called setclosed after i added all the vertices, but i'll have to check again. fact is, that i ported some code from arx to dwgdirect and the ported code failed because setclosed did not work the same.
simon
as i know setclosed/isclosed do not worry about vertices. closed is a flag in polyline.
for example if you have polyline with 3 vertices it is rendered as 2 connected lines if closed is set to false and as a triangle if closed is set to true.
i would appreciate if you could supply more info about the difference between how it works in arx and dd.
sergey slezkin
quote:
originally posted by sergey slezkin
as i know setclosed/isclosed do not worry about vertices. closed is a flag in polyline.
for example if you have polyline with 3 vertices it is rendered as 2 connected lines if closed is set to false and as a triangle if closed is set to true.
i would appreciate if you could supply more info about the difference between how it works in arx and dd.
that's what i expected. anyway, i tried to create a simple example that exhibits the failing of setclosed(). however, i did not succeed. the application where i had the problem is a little bit more complex, so it might be something else. i'll let you know if i find out anything.
simon
isclosed, again...
hi
so i've finally stumbled across this problem again. i've created a very simple dwg with just one polyline (it's a oddbpolyline) consisting of three segments (line segment, arc segment, line segment). the isclosed flag in autocad is explicitely set to false, the polyline is not closed. when i read the dwg with dwgdirect, the isclosed method returns always true. i could attach the dwg but i think it does not matter.
i read the file with:
code:
oddbdatabaseptr pdatabase = m_svcs->readfile(name);
and iterate over all entities in the model space with
code:
oddbblocktablerecordptr pblock = pdatabase->getmodelspaceid().safeopenobject();
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
oddbentityptr pent = pentiter->objectid().safeopenobject();
odsmartptr<oddbentityhandler> penthandler = pent;
penthandler->handle(pent, &handler);
}
inside the entity handler i use the following statement:
code:
void handle(oddbentity* pent, idwgentityhandler* handler) const
{
oddbpolygonmeshptr pmesh = pent; // (1)
handler->handlepolygonmesh(pmesh);
}
is there a problem with statement (1) and some virtual/non-virtual methods?
i'll try to reproduce the problem tomorrow without the protocol extension stuff.
simon
ps: i use dwgdirect 1.11 update 1
isclosed and odreadex
strange, i could not reproduce the behavior with odreadex. everything works as it should. any ideas what could be wrong in my case? i'll have to investigate further...
i've implemented the simplest possible application for reading just my simple dwg. and once again it works. i'm wondering if it has anything to do with the libraries i'm using. so far, the mt libs seem to work perfect. the version with the isclosed problems uses the md libraries. so i'll try once again with the md libraries...
ps: i'm using vc2003

i cannot reproduce the problem with simple applications. our real application uses managed c++ to read a dwg. could there be a problem related to the use of dwgdirect with managed c++? i'm just guessing, it's so strange!

well. it seems that my blind guess was correct. as soon as i use managed c++ isclosed returns always 1! i have a managed c++ dll project that just reads my test dwg and prints out, whether a polyline is closed or not. this managed c++ dll is referenced from a csharp command line app that calls the read method.
the interesting point is, that the very same code does work in pure c++, it just fails in my current (managed) setup. i post the code reading the file:
code:
oddbdatabaseptr pdatabase = svcs->readfile(filename);
oddbblocktablerecordptr pblock = pdatabase->getmodelspaceid().safeopenobject();
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
oddbentityptr pent = pentiter->objectid().safeopenobject();
oddbpolylineptr ppoly = pent;
cout << " => " << ppoly->isclosed() << endl;
}
note, there are only polylines in the test dwg...
so, i really have no clue what the problem could be. some project setting, linker option, ...??? do you need more information?
any help is really appreciated!
simon

should i post my complete example project including the dwg? i really don't see how i could solve this.
please post the entire project (or mail it to ), and we will look into the problem.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】value of drawing check yang686526 American standards 0 2009-05-04 11:08 AM
【转帖】notes on drawings not being read yang686526 American standards 0 2009-04-29 09:00 PM
【转帖】decimal dimensioningfractional equivalents yang686526 American standards 0 2009-04-29 07:28 PM
【转帖】can a 32 bit solidworks add-in work with 64 bi yang686526 SolidWorks二次开发 0 2009-04-13 09:28 AM


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


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