高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】conting entitites in a database
conting entitites in a database
conting entitites in a database
i need to count the number of each entity in an oddatabase model space.
so i iterate over the entities and get pent->isa()->name() and dxfname().
that is the only way, i guess , to know the entity type.
but i cant find a .h file in the kit which would contain an enumeration of all
the rxclass names or dxf names.
where are they ?
thanks for any help.
jp
last edited by dublin; 3rd september 2006 at 09:45 pmfff">.
there is no such single file. we have defines like
for .h files (declaration macros)
oddb_declare_members(oddbblockbegin);
and for .cpp (definition macros)
odrx_no_cons_define_members_altname(oddbdimension, oddbentity, dd_t("acdbdimension"))
ps : mfcapp has view\classes info. it shows all registered classes.
last edited by sslezkin; 4th september 2006 at 12:28 amfff">.
i need to count entities....
hi alexande,
so how can i design a switch/case on entity types with new kit...?
with the old kit, we did a switch/case on adenhd->enttype:
adgetblockhandle(rdhandle,mspaceblkobjhandle,ad_mo delspace_handle);
entlist=adentitylist(rdhandle,mspaceblkobjhandle);
adstartentityget(entlist);
for (entset=0; entset<2; entset++)
{
do
{
if (!(returnval=adgetentity(entlist,adenhd,aden))) continue;
switch (adenhd->enttype)
{
case ad_ent_line: ilines++; break;
case ad_ent_point: ipoints++; break;
etc..
how to do this with the new kit ?
thanks
jph
hi,
new toolkit uses odrxclass* instead entityid. unfortunately, switch\case construction cannot be used with.
the next is entity test for oddbregion.
code:
bool b = pent->isa() == oddbregion::desc();
or something like
code:
if (!pent.isnull()
&& (pent->iskindof(oddbregion::desc())
|| pent->iskindof(oddbbody::desc())
|| pent->iskindof(oddb3dsolid::desc())))
ps : readex example is database dump example. it can be useful for your task.
odreadex demonstrates more efficient method than
if (iskindof())
..
else if(
it uses protocol extensions.
sergey slezkin
understood !
thanks to all of you
jp
nevertheless ...
neverthe less, whatever the method we use , i stay convinced that there should be somewhere in the kit an enumaration of all dbobjects that the kit knows about because the client must supply a class for each known entities.
for exemple, the odreadex sample supplies a set of dumpers, enumerated in the class dumpers{}; and it looks to me that some entities are missing :
oddb2dvertex, oddbattribute, oddbattributedefinition, and may be others...
instead of having to dig around all the .h files with a good chance to miss some entities ( not all of us know the internals of autocad !) , it would be better to have a summ-up of all entities. and what about the next dd release if ac adds new db objects ?
jp
class dumpers
{
odstaticrxobject< oddb2lineangulardimension_dumper > m_2lineangulardimensiondumper;
odstaticrxobject< oddb2dpolyline_dumper > m_2dpolylinedumper;
odstaticrxobject< oddb3pointangulardimension_dumper > m_3pointangulardimensiondumper;
odstaticrxobject< oddb3dpolyline_dumper > m_3dpolylinedumper;
odstaticrxobject< oddb3dsolid_dumper > m_3dsoliddumper;
odstaticrxobject< oddbaligneddimension_dumper > m_aligneddimensiondumper;
odstaticrxobject< oddbarcalignedtext_dumper > m_arcalignedtextdumper;
odstaticrxobject< oddbarcdimension_dumper > m_arcdimensiondumper;
odstaticrxobject< oddbarc_dumper > m_arcdumper;
odstaticrxobject< oddbblockreference_dumper > m_blockreference;
odstaticrxobject< oddbbody_dumper > m_bodydumper;
odstaticrxobject< oddbcircle_dumper > m_circledumper;
odstaticrxobject< oddbdiametricdimension_dumper > m_diametricdimensiondumper;
odstaticrxobject< oddbellipse_dumper > m_ellipsedumper;
odstaticrxobject< oddbentity_dumper > m_entitydumper;
odstaticrxobject< oddbface_dumper > m_facedumper;
odstaticrxobject< oddbfcf_dumper > m_fcfdumper;
odstaticrxobject< oddbhatch_dumper > m_hatchdumper;
odstaticrxobject< oddbleader_dumper > m_leaderdumper;
odstaticrxobject< oddbline_dumper > m_linedumper;
odstaticrxobject< oddbminsertblock_dumper > m_minsertblock;
odstaticrxobject< oddbmtext_dumper > m_mtextdumper;
odstaticrxobject< oddbmline_dumper > m_mlinedumper;
odstaticrxobject< oddbole2frame_dumper > m_ole2framedumper;
odstaticrxobject< oddbordinatedimension_dumper > m_ordinatedimensiondumper;
odstaticrxobject< oddbpoint_dumper > m_pointdumper;
odstaticrxobject< oddbpolyfacemesh_dumper > m_polyfacemeshdumper;
odstaticrxobject< oddbpolygonmesh_dumper > m_polygonmesh;
odstaticrxobject< oddbpolyline_dumper > m_polylinedumper;
odstaticrxobject< oddbproxyentity_dumper > m_proxyentitydumper;
odstaticrxobject< oddbradialdimension_dumper > m_radialdimensiondumper;
odstaticrxobject< oddbrasterimage_dumper > m_imagedumper;
odstaticrxobject< oddbray_dumper > m_raydumper;
odstaticrxobject< oddbregion_dumper > m_regiondumper;
odstaticrxobject< oddbrotateddimension_dumper > m_rotateddimensiondumper;
odstaticrxobject< oddbshape_dumper > m_shapedumper;
odstaticrxobject< oddbsolid_dumper > m_soliddumper;
odstaticrxobject< oddbspline_dumper > m_splinedumper;
odstaticrxobject< oddbtable_dumper > m_tabledumper;
odstaticrxobject< oddbtext_dumper > m_textdumper;
odstaticrxobject< oddbtrace_dumper > m_tracedumper;
odstaticrxobject< oddbviewport_dumper > m_viewportdumper;
odstaticrxobject< oddbwipeout_dumper > m_wipeoutdumper;
odstaticrxobject< oddbxline_dumper > m_xlinedumper;
... what about oddb2dvertex, oddbattribute, oddbattributedefinition, ??
}
in autocad where is a set of built-in (say r12) entities which is stable. other db classes are an extensions from file format point of view. they are enumerated in classes section of dwg or dxf file.
some of them are added in latest autocad releases. but some of them are custom (client created) classes which are implemented by plug-ins. in autocad such plug-ins (dlls) are called .arx applications. in dd where is an equivalent - drx (can be dll or statically linked modules). any autocad user has ability to implement his own db classes using autocad's arx interface. or dd user can implement his db classes using drx (see excustobjs sample).
so you can never be sure that you know all classes which may present in drawing.
the set of "known" classes depends on the set of modules available for application (plug-ins).
if autocad (or dd) loads a file with unknown classes they come as proxy object or proxy entity. proxies store original data which is used to restore original objects if a module implementing this class is available. proxy entitiy also can store its graphic representation to draw the entity if its class is unknown for application.
as for readex its only a sample and does not pretend to dump even all r12 classes.
sergey slezkin
so the question remains to know where we can find the list of ac "stable" entities ( excluding proxies of course..). i mean the entities that autocad itself produces when there are no user .arx objects ...
rgds
jp
autocad itself contains a set of arx applications which varies not only between autocad versions but between different installations of the same version. for example if you chose "install expresstools" while installing autocad a few classes is added to "known" ones: wipeout, arcalignedtext, rtext...
the "fixed" set presents in old c toolkit enum for enttype.
btw, variable set of "optional" classes is the reason why some classes in odt have "floating" enttype value.
sergey slezkin
|