几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】reading data from a dwg file (http://www.dimcax.com/hust/showthread.php?t=18349)

yang686526 2009-05-07 12:32 PM

【转帖】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


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