Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Shape factory
Shape gallery
What's new
System requirements
Download Center
Public license
Getting started
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
Home / Developer Corner / Forums / Usage issues / How to get the TDF_Label of the currently selected shape?

How to get the TDF_Label of the currently selected shape?

How to get the TDF_Label of the currently selected shape?
Marko Knöbl 2012/12/15 04:40

I am developing a CAD program in which I am using a TDocStd_Document and displaying its contents through a V3d_Viewer.
Now I am searching for a way to get the label of the shape which is currently selected in the viewer. I can get the shape by calling "myViewer->Context->SelectedShape()".
Is there a simple way to retrieve the associated TDF_Label?
I want to use it e.g. to change the color of the shape or to remove the shape from the document.

PS: I'm using the pythonOCC bindings to work with OCC. I only have little experience with C++, but I think I will be able to understand code examples if you post some.

Thanks in advance,
seumonkey 2012/12/16 06:16
     Hi, try this:
if (myContext->MoreCurrent()) {
Handle(TPrsStd_AISPresentation) ObjectPrs = Handle(TPrsStd_AISPresentation)::DownCast(myContext->Current()->GetOwner());
if (ObjectPrs.IsNull())
return NULL;

TDF_Label Label = ObjectPrs->Label();
Marko Knöbl 2012/12/18 06:06
Thanks for your answer!

Unfortunately it does not work as expected for me: It always returns label "0:1:1:1" no matter which shape I selected.
I can imagine that this is because I am already making an error when adding a shape to my document (I never truly understood what was going on there, but it mysteriously worked) - Could that be the cause of the problem?

Anyhow now I see that I'll have to use TPrsStd_AISPresentation for this task - This is already very valuable information for me.

Thank you!
Latest news
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map