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

retrieving correct handles for insert attributes when explod
retrieving correct handles for insert attributes when exploding nested inserts
perhaps i don't understand the classes enough yet, but it seems to me that i cannot obtain the entity handles from attributes on nested inserts.
if i have an insert within the model_space then i can iterate through the attributes of the insert and get the correct handles for the attributes. however, if i explode the insert to get at the insert entities within it, how can i then get the handles of the attributes on those nested inserts?
all the attributes that belong to the nested inserts seem to have handles of '0'. please note that the nested inserts do belong to the database and are not free entities, either from being reinserted into a new block or due to using explodetoblock().
i would appreciate any advice that can be offered in this situation.
thanks in advance.
to access entities from nested block insertions you need not explode insert entity. you can get block table record id from insert entity and iterate through inserted block recurcively.
explode operation erases attribute entities - insert entity is replaced with the contents of block transformed according to insert parameters (together with attribute definitions).
explode() produces an array of non-database resident entities which have no handles.
sergey slezkin

ok. i understand that exploding the block inserts is not the solution for getting the attributes, but i will have to do that later to get the entities anyway, since i need both together.
so from my understanding you are saying the process to get the attributes from an insert or nested insert would look like:
start:
if (pentity->iskindof(oddbblockreference::desc()))
{
call attributeiterator() to read the attributes of this insert and
retrive thier handles
get the block table record id (pentity->blocktablerecord())
iterate through the entities in the block table record and get the
original entity handles from those entities.
if the entity is an insert goto start.
}
ignoring the stunning use of the goto statement to ease the reading of the pseudo code, is this process correct?
this seems to imply that in order to get the correct nested attribute handles associated with the attributes themselves, i need first to perfrom something similar to the process above and then recursively explode the entities, and then reapply the handles to the exploded entities.
is there no easier way to do this? it seems like a lot of overhead just to get the correct handles for the attribute entities on an insert.
if you need to get attributes/entities you need not explode anything. explode operation is the overhead if you simply need to get the information from database without modifying it.
processblock(oddbobectid idblock)
{
oddbblocktablerecordptr pblock = idblock.openobject();
oddbobjectiteratorptr pents = pblock->newiterator();
while(!pents->done())
{
oddbentityptr pent = pents->entity();
pents->step();
if (pent->iskindof(oddbblockreference::desc())
{
oddbblockreferenceptr pins = pent;
oddbobjectiteratorptr pattribs = pins->attributesiterator();
// process attributes
...
// process nested block recurcively
processblock(pins->blocktablerecord());
}
else
{ process non-insert entity
}
}
}
sergey slezkin
recursion is a standard way to access elements of a tree in this nature. there are algorythms <sp> out there which are non-recursive to traverse a tree. however, i believe the recursive method is much simpler.
thanks for your help. this leads to another question about whther i need to call explode() at all. it sounds liek you are saying i do not. currently the only reason i am doing an explode is to get the entities out in the right positions, with offsets and rotations etc.
i am trying to get the information on the nested inserts in order to draw all the entities properly (not using the dwg direct to render). currently i am using the explode() function to get the correct offsets, scale, rotation etc for the nested entities.
it would be a lot easier if i did not have to explode(). what calls would i need to make to have the nested entities inserted properly? i think it has something to to with the blockttransform() and transformby() calls, but i am not sure if that all there is to it...
can you provide code that would replace the transformation process in the explode() call?
thanks.
using explode method to get transformed entities is a wrong way. it leads to huge overhead and not all entities can be transformed by any transformation. for example block insertions and 3dsolids can't be transformed if scale is non-uniform.
you need to keep transformation stack, pushing block reference transform then you step into a block and poping transform exiting nested block. you also need to worry about properties having byblock value.
this can be easily done using dd render. if you want to get entities not their geometry you can override odgigeometry::draw() method.
sergey slezkin
are there any examples of using a transformation stack to handle nested blockreferences?
quote:
originally posted by sergey slezkin
using explode method to get transformed entities is a wrong way. it leads to huge overhead and not all entities can be transformed by any transformation. for example block insertions and 3dsolids can't be transformed if scale is non-uniform.
you need to keep transformation stack, pushing block reference transform then you step into a block and poping transform exiting nested block. you also need to worry about properties having byblock value.
this can be easily done using dd render. if you want to get entities not their geometry you can override odgigeometry::draw() method.
sergey, how do i override odgigeometry::draw() method? i tried lot of things using the example programs and the forum mails, but my logic fails in one case or the other. do you have any sample code for this? thanks.
regards,
saroja
odvectorizeex sample contains example of overriding draw() in exsimpleview class.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】problem exploding blockref containing attributes yang686526 DirectDWG 0 2009-05-06 10:42 PM
【转帖】missing attributes yang686526 DirectDWG 0 2009-05-06 05:51 PM
【转帖】incorrect block with attributes yang686526 DirectDWG 0 2009-05-06 03:47 PM
【转帖】attributes in a block a not shown at the correct position yang686526 DirectDWG 0 2009-05-04 04:23 PM


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


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