Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
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