Problem with placing a UDF on a sketch as reference.
I have a problem placing a UDF with a reference that is not contained in the parent part.
Let's have a look at the following code, which is working as expected:
pfcAssembly_ptr assembly = pfcAssembly::cast(session->GetActiveModel());
logFile << "assembly: " << assembly->GetFullName() << endl;
pfcSolid_ptr skeleton = assembly->GetSkeleton();
logFile << "skeleton: " << skeleton->GetFullName() << endl;
pfcFeature_ptr partItem = assembly->ListFeaturesByType(false, pfcFEATTYPE_COMPONENT)->get(1);
pfcModelDescriptor_ptr desc = pfcComponentFeat::cast(partItem)->GetModelDescr();
pfcPart_ptr part = pfcPart::cast(session->GetModelFromDescr(desc));
logFile << "part: " << part->GetFullName() << endl;
pfcModelItem_ptr sketchItem = part->GetItemByName(pfcITEM_FEATURE, "SKETCH");
logFile << "sketchItem: " << sketchItem << endl;
pfcSelection_ptr selection = pfcCreateModelItemSelection(sketchItem);
logFile << "selection: " << selection << endl;
pfcUDFReference_ptr reference = pfcUDFReference::Create("udf_sketch", selection);
pfcUDFReferences_ptr references = pfcUDFReferences::create();
references->append(reference);
logFile << "references: " << references << endl;
pfcUDFCustomCreateInstructions_ptr instructions = pfcUDFCustomCreateInstructions::Create("C:\\path\\to\\ufd.gph");
instructions->SetDimDisplayType(pfcUDFDISPLAY_BLANK);
instructions->SetReferences(references);
logFile << "instructions: " << instructions << endl;
pfcFeatureGroup_ptr udf = part->CreateUDFGroup(pfcUDFCustomCreateInstructions::cast(instructions));
logFile << "success!" << endl;
It places a UDF inside the part, with a sketch of the part as reference.
Now let's try the same again, but with a sketch of the skeleton as reference (changing only this one line):
pfcModelItem_ptr sketchItem = skeleton->GetItemByName(pfcITEM_FEATURE, "SKETCH"); // instead of part->GetItemByName
The sketch gets found and selected (according to logging output). But part->CreateUDFGroup causes an error:
pfcExceptions::XToolkitGeneralError
{
Message : "pfcExceptions::XToolkitGeneralError"
MethodName : "ProUdfCreate"
ToolkitFunctionName : "pfcSolid::Solid::CreateUDFGroup"
}
Creo then tells me to correct an invalid reference to a sketch.
It's possible to reference the UDF to this sketch via Creo UI. So, what's wrong with the code?
Any help or working code (regardless of the programming language) would be highly appreciated.

