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

deleted entities
deleted entities
hello,
i have one question.
if i delete an entity from oddbdatabase, like this:
oddbentityptr pent = ptr->safeopenobject(oddb::kforwrite);
pent->erase();
i have noticed, that i can get the deleted entity later:
oddbentityptr pent = ptr->safeopenobject(oddb::kforwrite);
when is this entity realy removed from database. is it safe to reference such entity at any time? or is this entity really deleted from oddbdatabase before file is created.
can i read the attributes of deleted entities at any time, or it is possible, that
entity is really erased, and ptr->safeopenobject() will raise an exception?
best regards, tomaz
hi tomaz,
to delete an entity from the database,
oddbentityptr pent = ptr->safeopenobject(oddb::kforwrite);
pent->erase();
is the only way to do it. be aware that this is functionality of oddbobject, so you can delete any other database object in this way, and not only entities.
however, no destructor of the c++ object is called here, and the data of the entity is not erased. only an erased flag internally is set to true. the reason for this is very simple - if you delete the c++ object, no undo/redo could be performed afterwards.
so for, when the database tables or dictionaries are iterated, usually the erased objects are skipped. also the erased entities are not displayed (ignored during regen operation).
unless an undo operation is performed and the object turns back its erased flag to false.
please note the arguments when you create new iterator and its members - for example see the oddbsymboltableiterator class. you usually call start() member function to start the iteration - and the second argument of the start() member is a bool flag skipdeleted - if you set to false, then you will have the erased objects also iterated.
if you call this:
oddbentityptr pent = ptr->safeopenobject(oddb::kforwrite);
of an erased entity, an exception "object already erased" or similar would be thrown. i don't know why you succeeded in opening the erased object again with no exception by calling this way.
to open an erased object, you should call
id.safeopenobject(oddb::kforread (or oddb::kforwrite), true), because the second flag of this function indicates whether an erased object is allowed to be opened.
the thus erased object is removed from the database only when the database is closed (i.e. destroyed). when you open it again, the object should not be there. (but once i had forgotten an object id of erased entity, and after re-opening the database, the exception was object was permanently erased, which was a very bad bug).
so you can read the attributes of an erased entity by opening it with safeopenobject(read or write, true), but i don't know whether you should really need this. when you iterate entities or objects in a standard way and leave the iterator arguments to their default values, you'll get no erased objects.
hope this helps you.
regards
chudomir
hello chudo,
this answer really helps me a lot.
and you are right, i got the exception when i called
oddbentityptr pent = ptr->safeopenobject(oddb::kforwrite);
on erased entity.
thanks for your help
best regards, tomaz
undo recording can be turned off (oddbhostappservices::newundocontroller() returns null or undo is disabled at database or at object level).
in such case objects get erased permanently and memory is freed. but this was temporary disabled in 1.10
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】coping entities yang686526 DirectDWG 0 2009-05-04 06:18 PM
【转帖】block entities are not erased after the block deleting yang686526 DirectDWG 0 2009-05-04 04:46 PM
【转帖】avoiding to read block definitions as entities yang686526 DirectDWG 0 2009-05-04 04:33 PM
【转帖】objectarx&dummies教程(十三)—— deriving from acdbentity yang686526 ObjectARX(C++) 0 2009-04-16 10:40 AM
【转帖】objectarx&dummies习题(一)—— creating and editing entities yang686526 ObjectARX(C++) 0 2009-04-16 10:32 AM


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


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