Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi,
I use the ProUIListActivateActionSet() function to execute an action.
Once the process is completed when I activate Cancel button, creo crashes.
Kindly throw some light on this
Solved! Go to Solution.
try this once:
void test(char* dialog, char* component, ProAppData data)
{
ProError err;
ProMdl CurMdl;
ProMdlType CurMdlType;
ProSelection *SelDim;
ProDimension Dim, *MdlItm = &Dim;
ProLine DimText;
int SelCount, i;
wchar_t** suffix = NULL;
err = ProArrayAlloc(2, sizeof(wchar_t *), 1, (ProArray *)&suffix);
suffix[0] = L"@D";
suffix[1] = L"Test";
err = ProMdlCurrentGet(&CurMdl);
if (err == PRO_TK_NO_ERROR)
err = ProMdlTypeGet(CurMdl, &CurMdlType);
if ((err == PRO_TK_NO_ERROR) && (CurMdlType == PRO_MDL_DRAWING))
err = ProSelect("dimension", 1, NULL, NULL, NULL, NULL, &SelDim, &SelCount);
if ((err == PRO_TK_NO_ERROR) && (SelCount != 0))
{
err = ProSelectionModelitemGet(SelDim[0], MdlItm);
err = ProDimensionTextWstringsSet(MdlItm, suffix);
}
err = ProArrayFree((ProArray *)&suffix);
}
AFIK, check with memory management. Nothing to do with API. Try to allocate memory and free the same after usage.
For example,
char* list is required for an argument to suggested API. You should do it like this
char* list = new char[500]///this should also be used dynamically
post usage of this variable, deallocate the same with delete[] list.
It's difficult to track memory issue if it is really a issue. Share code if possible to have a look once I get time.
void test(char* dialog, char* component,ProAppData data) { ProError err; ProMdl CurMdl; ProMdlType CurMdlType; ProSelection *SelDim; ProDimension Dim, *MdlItm = &Dim; ProLine DimText; int SelCount,i; err = ProArrayAlloc(2, sizeof(wchar_t *), 1, (ProArray *)&suffix); suffix[2] = (wchar_t *)calloc(PRO_NAME_SIZE, sizeof(wchar_t)); suffix[0]=L"@D"; suffix[1]=L"Test"; err = ProMdlCurrentGet(&CurMdl); if (err == PRO_TK_NO_ERROR) err = ProMdlTypeGet(CurMdl,&CurMdlType); if ((err == PRO_TK_NO_ERROR) && (CurMdlType == PRO_MDL_DRAWING)) err = ProSelect("dimension",1,NULL,NULL,NULL,NULL,&SelDim,&SelCount); if ((err == PRO_TK_NO_ERROR) && (SelCount!=0)) { err = ProSelectionModelitemGet(SelDim[0],MdlItm); err = ProDimensionTextWstringsSet(MdlItm,suffix); } if (err == PRO_TK_NO_ERROR) err = ProDwgSheetRegenerate((ProDrawing)CurMdl,1); err = ProArrayFree((ProArray *)&suffix); } ProError test() { err = ProUIListActivateActionSet(DLG,"myNotes",(ProUIAction)test,NULL); }
try this once:
void test(char* dialog, char* component, ProAppData data)
{
ProError err;
ProMdl CurMdl;
ProMdlType CurMdlType;
ProSelection *SelDim;
ProDimension Dim, *MdlItm = &Dim;
ProLine DimText;
int SelCount, i;
wchar_t** suffix = NULL;
err = ProArrayAlloc(2, sizeof(wchar_t *), 1, (ProArray *)&suffix);
suffix[0] = L"@D";
suffix[1] = L"Test";
err = ProMdlCurrentGet(&CurMdl);
if (err == PRO_TK_NO_ERROR)
err = ProMdlTypeGet(CurMdl, &CurMdlType);
if ((err == PRO_TK_NO_ERROR) && (CurMdlType == PRO_MDL_DRAWING))
err = ProSelect("dimension", 1, NULL, NULL, NULL, NULL, &SelDim, &SelCount);
if ((err == PRO_TK_NO_ERROR) && (SelCount != 0))
{
err = ProSelectionModelitemGet(SelDim[0], MdlItm);
err = ProDimensionTextWstringsSet(MdlItm, suffix);
}
err = ProArrayFree((ProArray *)&suffix);
}