entity type

entity type

johnteng00
Advocate Advocate
1,033 Views
4 Replies
Message 1 of 5

entity type

johnteng00
Advocate
Advocate

Hi guys,

 

I use c++. When user select an entity, I want to find out the entity type.

 

Certainly I can use: AcDb3dSolid::cast(obj) or similar approach to find the right type I need. But I want to know is there are other ways to find the entity type.

 

Thank you

Eric

 

Accepted solutions (1)
1,034 Views
4 Replies
Replies (4)
Message 2 of 5

hbxiaogui
Advocate
Advocate
Accepted solution
ent->isA()==AcDb3dSolid::desc()
ent->isKindOf(AcDb3dSolid::desc())
0 Likes
Message 3 of 5

johnteng00
Advocate
Advocate

good, thank you for your reply.

0 Likes
Message 4 of 5

tbrammer
Advisor
Advisor

You can also use   AcRxClass* AcDbObjectId::objectClass() const    to query the class from the AcDbObjectId without even opening the object.

 

Sometimes you might also want to test for a base class:

ent->isDerivedFrom(AcDbDimension::desc())

This would be true if ent is any kind of dimension.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 5

autodaug
Autodesk
Autodesk

Just to clarify, isKindOf() is a method of AcRxObject, while isDerivedFrom() is a method of AcRxClass.  So the method you want to call depends on whether you're pointing to the entity or to its class object.  If ent points to an AcDbEntity and id is its AcDbObjectId, then you can check for it being a dimension in these ways:

ent->isKindOf(AcDbDimension::desc())
// or:
ent->isA()->isDerivedFrom(AcDbDimension::desc())
// or:
id.objectClass()->isDerivedFrom(AcDbDimension::desc())

 And to make it more confusing, AcRxClass itself is derived from AcRxObject, so it's possible, although usually incorrect and unintended, to do this:

id.objectClass()->isKindOf(AcDbDimension::desc())

That will always return false because objectClass() returns a pointer to an AcRxClass object, and AcRxClass itself is not derived from AcDbDimension. It derives directly from AcRxObject.

0 Likes