Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
I have the same question.
Any ideas will be helpful.
I found a way to create new text in a scketch
ProError SketchedTextReplace (ProFeature *feat, ProName refdestext)
{
ProError status;
ProSection section;
ProIntlist ent_ids;
int n_ids;
Pro2dEntdef *p_ent;
Pro2dTextdef *mytext;
ProElement featElemTree;
ProElement sketcherElem;
ProElempath sketcherElemPath;
status = ProFeatureElemtreeExtract(feat, NULL, PRO_FEAT_EXTRACT_NO_OPTS, &featElemTree);
//Get section
ProElempathItem sketcherElemPathItem[2] = {
{PRO_ELEM_PATH_ITEM_TYPE_ID, PRO_E_STD_SECTION},
{PRO_ELEM_PATH_ITEM_TYPE_ID, PRO_E_SKETCHER}};
status = ProElempathAlloc(&sketcherElemPath);
status = ProElempathDataSet(sketcherElemPath, sketcherElemPathItem, 2);
status = ProElemtreeElementGet(featElemTree, sketcherElemPath, &sketcherElem);
if (status != PRO_TK_NO_ERROR) //Not a section
{
return status;
}
status = ProElementSpecialvalueGet(sketcherElem, NULL, (ProAppData*) §ion);
status = ProSectionIntentManagerModeSet(section, PRO_B_TRUE);
status = ProSectionEntityIdsGet(section, &ent_ids, &n_ids);
for (int i=0; i<n_ids; i++)
{
status = ProSectionEntityGet(section, ent_ids[i], (Pro2dEntdef**)&mytext);
if (mytext->type == PRO_2D_TEXT)
{
Pro2dTextdef newtext;
int newtext_id;
ProWSecerror sec_errs;
//copy parameters from old text
newtext.type = mytext->type;
newtext.first_corner[0] = mytext->first_corner[0];
newtext.first_corner[1] = mytext->first_corner[1];
newtext.second_corner[0] = mytext->second_corner[0];
newtext.second_corner[1] = mytext->second_corner[1];
status = ProWstringCopy(mytext->font_name, newtext.font_name, PRO_VALUE_UNUSED);
status = ProWstringCopy(refdestext, newtext.string, PRO_VALUE_UNUSED);
status = ProSectionEntityAdd (section, (Pro2dEntdef*)&newtext, &newtext_id);
status = ProSectionEntityDelete (section, ent_ids[i]);
status = ProSecerrorAlloc (&sec_errs);
int n_errors;
status = ProSectionRegenerate (section, &sec_errs);
status = ProSectionIntentManagerModeSet(section, PRO_B_FALSE);
status = ProSecerrorFree (&sec_errs);
//Redefine feature
ProFeatureCreateOptions *featCreationOpts = NULL;
status = ProArrayAlloc(1, sizeof(ProFeatureCreateOptions), 1, reinterpret_cast<ProArray *>(&featCreationOpts));
featCreationOpts[0] = PRO_FEAT_CR_NO_OPTS;
ProErrorlist errorList;
status = ProFeatureWithoptionsRedefine(NULL, feat, featElemTree, featCreationOpts, PRO_REGEN_NO_FLAGS, &errorList);
ProArrayFree ((ProArray*)&featCreationOpts);
return status;
}//if
}//for
return PRO_TK_E_NOT_FOUND;
}
