查看单个帖子
旧 2009-05-07, 12:32 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】reading data from a dwg file

reading data from a dwg file
reading data from a dwg file
hi,
i have to write a c++ program which reads some data from a dwg file and writes it into a text file. i've already studied the odreadex example project, but i'm stuck. i want to read some attributes from the dwg file. anyone who can help me?
thanks in advance!
hi,
you want to read some attribute entities (related to block inserts)? or simply some common entity properties - if so then which exactly do you want to read?
best regards
chudomir
quote:
originally posted by chudo
hi,
you want to read some attribute entities (related to block inserts)? or simply some common entity properties - if so then which exactly do you want to read?
i want to read the attribute entities related to block inserts and find some attribute entities with a certain name and write the name of the attribute and the value to a text file. how can i iterate all block inserts and read the attributes related to them?
to get all the block references (this example is for the model space):
code:
oddbblocktablerecordptr pmodelspace = pdb->getmodelspaceid().safeopenobject();
oddbobjectiteratorptr pi = pmodelspace->newiterator();
for (pi->start(); !pi->done(); pi->step()) {
oddbentityptr pent = pi->entity();
if (pent->iskindof(oddbblockreference::desc())) {
oddbblockreferenceptr pblockref = pent;
/*here you can use the block reference*/
/*see the docs for more information about oddbblockreference::attributeiterator and oddbattribute*/
} //if
} //for
(i haven't compile this so if you have any problems please let me know; also exceptions are possible to be thrown, so catch(oderror&) is needed at outer level)
hope this helps...
best regards
chudomir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)