Skip to main content
4-Participant
July 8, 2024
Question

How to correctly obtain a Driving Dimension from a selection buffer in Creo OTK?

  • July 8, 2024
  • 1 reply
  • 805 views

Dear PTC Community,

I am currently trying to obtain a selected driving dimension from the selection buffer in my Creo session. My current approach is to start by getting the current selection buffer:

 

pfcSession_ptr _session = pfcGetProESession();
pfcSelectionBuffer_ptr selBuffer = _session->GetCurrentSelectionBuffer();

 

Then, I list and iterate over the selected items and filter out all selected annotation elements:

 

pfcSelections_ptr currentSelections = selBuffer->GetContents();
size_t sizeSelection = currentSelections->getarraysize();
for (xint i = 0; i < sizeSelection; i++) {
 pfcSelection_ptr selection = currentSelections->get(i);
 pfcModelItem_ptr item = selection->GetSelItem();
 if (item->GetType() == pfcITEM_ANNOTATION_ELEM) {
 wfcAnnotationElement_ptr anno = wfcAnnotationElement::cast(item);
 wfcAnnotationType annoType = anno->GetAnnotationType();
 if (annoType == wfcANNOTATION_DIMENSION) {
 [...]
 }
 }
}

 

However, in line 10 where I call

 

wfcAnnotationType annoType = anno->GetAnnotationType();

 

, I get a pfcXInvalidEnumValue exception.

 

If I use TK code instead of OTK code inside the for loop, everything works just fine:

 

ProAnnotationElem* aElem = (ProAnnotationElem*)wfcGetHandleFromObject(pfcObject::cast(item));
ProAnnotationType type;
ProError err = ProAnnotationelemTypeGet(aElem, &type);
[...]

 

Upon inspection of the returned type, my debugger returns a PRO_ANNOT_TYPE_DRIVINGDIM.

 

How can I correctly obtain a selected driving dimension using OTK?

 

Creo Version: 10.0.2.0

1 reply

Community Moderator
July 11, 2024

Hi @kirschlu,

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Regards,

Vivek N
Community Moderation Team.