how to convert from AIS_InteractiveObject to AIS_Shape?

Hi.

In document, there is no solution and method. So i ask.

There is no way to convert?

Venugopal Gudimetla's picture

Hi Yeon,

AIS_Shape is derived from AIS_InteractiveObject, so just Downcast AIS_InteractiveObject:

Handle(AIS_Shape) anAISObj = Handle(AIS_Shape)::DownCast(anAIS_InteractiveObj);
Venu

shudolf's picture

Thanks Venu.

Yeon Cheol

Sharjith Naramparambath's picture

To add my 2 cents, along with doing what Venu said, you can do a check if the AIS_InteractiveObject is really an AIS_Shape by calling the IsKind method. Like:

if(anInteractiveObj->IsKind(STANDARD_TYPE(AIS_Shape)))
{
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anInteractiveObj);
}

This is important because the objects like Trihedron also can be selected by the user and may get into your code where you try to downcast it to an AIS_Shape when it really isn't.

Venugopal Gudimetla's picture

Thanks Sharjith, learnt something today.

Venu

shudolf's picture

Thanks Sharjith

very useful information.

Yeon Cheol