Recognizing DynamicType for AIS_InteractiveObject-derived objects

I've made a new MyAISObject object by deriving it from AIS_InteractiveObject and everything works fine.

Now I would like to recognize it into a list of interactive objects, but of course the IsKind() routine is only able to recognize if the object is of AIS_InteractiveObject type, not MyAISObject.

What should I do to detect the type of derived objects?

Thanks in advance.

Roman Lygin's picture

Hi Fabio,

To take advantage of RTTI and safe typecast features of OCC handles you need to correctly define your type.

In your .hxx:


class MyAISObject : public AIS_InteractiveObject {


In implementation .cxx:

Now you should be able to use standard RTTI and typecast:

if (anObj->IsKind (STANDARD_TYPE (MyAISObject )) {
Handle (MyAISObject) aMyObj = Handle (MyAISObject)::DownCast (anObj);


If you use WOK and CDL, it does everything for you.

Hope this helps.

Fabio Napodano's picture

many thanks Roman,
actually I've figured it out yesterday but forgot to self-reply:
I've seen this done on the Geometry example.

Thanks for your interest: now I know I've made it the right way.