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

referenced entities
referenced entities
hello,
i am completely new to opendesignalliance and not a specialist of dxf/dwg data format.
is there is a way to reference an entity and to give it a transformation matrix to have several instance of the same object?
if yes, how can i access to this information with dwgdirect from a oddbentity entity of from the oddbobjectiteratorptr?
thank you a lot in advance for your answer.
guilhem
an entity (or a set of entities) can be put into a block (oddbblocktablerecord). the reference to block (oddbblockreference) can be inserted several times with different transformations representing multiple instances of geometry contained in block.
sergey slezkin
hello sergey,
thank you for your help. in fact i already have the oddbblockreferenceptr,
but i cannot find the way to know it is a reference to a source block...
i am using the code referred in:
in order to get the geometry of each block.
so, i have the simplified code, where the services and the vectorizer are
declared and initialized elsewhere:
code:
void blocktablerecord (oddbblocktablerecordptr btr,
odstaticrxobject<vectorizer> * vectorizer) {
/* iterate on each entity of the block */
for (oddbobjectiteratorptr i = btr->newiterator(); i->done() == false ; i->step()) {
/* get the dwg entity and its owner layer */
oddbentityptr dwg_entity = i->objectid().safeopenobject();
if (dwg_entity->iskindof (odgidrawable::desc())) {
/* draw the dwg entity */
try {
vectorizer->draw (dwg_entity);
}
catch (...) {
log_error ("error when processing layer [%ls]\n", dwg_entity->layer());
}
}
/* if the entity is a block reference, draw its sub blocks */
if (dwg_entity->isa() == oddbblockreference::desc()) {
/* process the children blocks */
this->blocktablerecord (((oddbblockreferenceptr) dwg_entity)
->blocktablerecord().safeopenobject(),
vectorizer);
}
}
}
code:
void openandprocessfile (char * filename) {
oddbdatabaseptr pdb = services.readfile (filename, false, false, oda::ksharedenyno);
if (! pdb.isnull()) {
/* create the rendering context and attach the database */
odstaticrxobject<odgicontextfordbdatabase> context;
context.setdatabase (pdb);
/* get the block table */
oddbblocktableptr table = pdb->getblocktableid().safeopenobject();
/* count the number of blocks */
oddbsymboltableiteratorptr i;
for (i = table->newiterator(); i->done() == false; i->step()) {
/* get the record */
oddbblocktablerecordptr record = i->getrecord();
/* process the record */
processer.blocktablerecord (record, & vectorizer);
}
}
}
i would like to find the way to know that the block is a reference
rather than a true block... i need also to know the source block
in order to make a reference to it with a transformation matrix...
thank you again for your help,
best regards
guilhem
i'm not sure what your task is. if you want to get geometry probably the good place to start from could be odvectorizeex sample.
blocktablerecords are containers holding entities. they are of 2 types: layout blocks (model and paper spaces). each layout has it's block holding entities of the layout. these (layout) blocks are not referenced by any block insertion entity (blockreference).
the blocks of other type (non-layout) can be referenced by blockreference entities storing transformation applied to block contents.
blockreferences can be inserted into layout blocks making referenced blocks visible in layout.
the process can be recursive: layout besides other entities may contain blockreference to some non-layout block which contains references to other blocks.
in order to get geometry of a layout (say model space) you need to process (recurcively because of block reference entities) the contents of the layout block. not the contents of all blocks in table.
sergey slezkin
sergey,
is the odvectorizeex sample allows to get the structure of the drawing in the dwg file (layers and internal blocks)? i have (quickly) test it and it seems that i got the whole geometry without the logical structure...
the sample from where i got my sources seems to be much more simpler than the odvectorizeex sample... but i am absolutely not sure that it meets my requirements...
many thanks for your help
guilhem
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】how to get the color of merged entities yang686526 DirectDWG 0 2009-05-06 02:44 PM
【转帖】hatching entities yang686526 DirectDWG 0 2009-05-05 12:01 PM
【转帖】exploding block references = invisible entities yang686526 DirectDWG 0 2009-05-05 10:17 AM
【转帖】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


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


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