Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello, I want to show current working folder files in UI with individual check box.
Here I tried below code, but its not working. Any one has solution to this?
void Assymode::StartAssy(ProMdl assyMdl)
{
ProError status;
ConvertParttoStep();
return;
}
void ConvertParttoStep()
{
ProError status;
int iDiaout;
ProPath *files_list, *dir_list;
int num;
status = ProArrayAlloc(0, sizeof(ProPath *), 1, (ProArray*)&files_list);
status = ProArrayAlloc(0, sizeof(ProPath *), 1, (ProArray*)&dir_list);
status = ProFilesList(NULL, L"*.prt,*.asm", PRO_FILE_LIST_LATEST, &files_list, &dir_list);
if (status == PRO_TK_NO_ERROR)
{
status = ProArraySizeGet((ProArray)files_list, &num);
wchar_t **model_names;
char **strings;
status = ProArrayAlloc(num, sizeof(wchar_t *), 1, (ProArray *)model_names);
status = ProArrayAlloc(num, sizeof(char *), 1, (ProArray *)&strings);
for (int i = 0; i < num; i++)
{
model_names[i] = (wchar_t *)calloc(PRO_MDLNAME_SIZE, sizeof(wchar_t));
strings[i] = (char *)calloc(PRO_MDLNAME_SIZE, sizeof(char));
status = ProMdlMdlnameGet((ProMdl)files_list[i], model_names[i]);
ProWstringToString(strings[i], model_names[i]);
}
status = ProUIDialogCreate("List", "List"); // Add UI to creo memory
status = ProUIPushbuttonActivateActionSet("List", "CommitOK", (ProUIAction)UIOKPB, NULL);
status = ProUIPushbuttonActivateActionSet("List", "CommitCancel", (ProUIAction)UICloseAction, NULL);
status = ProUIListNamesSet("List", "List1", num, strings);
status = ProUIListLabelsSet("List", "List1", num, model_names);
status = ProUIDialogActivate("List", &iDiaout); // DIsplay UI in Creo
status = ProUIDialogDestroy("List"); // Delete UI from Creo memory
status = ProUIDialogCloseActionSet("List", (ProUIAction)UICloseAction, NULL);
status = ProArrayFree((ProArray*)&files_list);
status = ProArrayFree((ProArray*)&dir_list);
status = ProArrayFree((ProArray*)&model_names);
status = ProArrayFree((ProArray *)&strings);
}
return;
}
ProError UIOKPB(char *dialog, char *component, ProAppData data)
{
ProError status;
status = ProUIDialogExit(dialog, 0);
return status;
}
ProError UICloseAction(char* dialog, char* component, ProAppData appdata)
{
ProError status = PRO_TK_NO_ERROR;
ProUIDialogExit(dialog, 0);
return status;
}
\\********************************//
(Dialog List
(Components
(SubLayout Content)
(Separator CommitSeparator)
(PushButton CommitClose)
)
(Resources
(CommitSeparator.ResourceHints "Template:CloseDialog.CommitSeparator")
(CommitClose.Label "Close")
(CommitClose.TopOffset 10)
(CommitClose.BottomOffset 10)
(CommitClose.LeftOffset 40)
(CommitClose.RightOffset 10)
(CommitClose.ResourceHints "Template:CloseDialog.CommitClose")
(.TopOffset 0)
(.BottomOffset 0)
(.LeftOffset 0)
(.RightOffset 0)
(.DefaultButton "CommitClose")
(.ResourceHints "Template:CloseDialog" "Guidelines:Creo4-Dialog" "GuidelinesVersion:1" "Version:Creo4" "@Subgrid0x2.Template:CloseDialog.CommitBar")
(.Accelerator "Esc")
(.AttachLeft True)
(.Layout
(Grid
(Rows 1 0 0)
(Cols 1)
Content CommitSeparator
(Grid
(Rows 1)
(Cols 1 0)
(Pos 1 2)
CommitClose
)
)
)
)
)
(Layout Content
(Components
(List List1)
)
(Resources
(List1.Names "ItemName1" "ItemName2")
(List1.Labels "Item1" "Item2")
(List1.TopOffset 0)
(List1.BottomOffset 0)
(List1.LeftOffset 0)
(List1.RightOffset 0)
(List1.ListType 2)
(.AttachLeft True)
(.AttachRight True)
(.AttachTop True)
(.TopOffset 16)
(.BottomOffset 16)
(.LeftOffset 10)
(.RightOffset 10)
(.ResourceHints "Template:CloseDialog.Content")
(.AttachBottom True)
(.Layout
(Grid
(Rows 1)
(Cols 1)
List1
)
)
)
)
If the array size is 0/zero try to add an asterisk at the end of a pattern.
ProFilesList(NULL, L"*.prt*,*.asm*", PRO_FILE_LIST_LATEST, &files_list, &dir_list);
because you will have
box.prt.43 and/or box.prt
And you need probably to parse for a valid integer and maybe to have a list to compare only the latest. Best would be a regular expression.
But this depends…
I just checked the header file
extern ProError ProFilesList (
ProPath directory_path,
ProLine filter,
ProFileListOpt listing_option,
ProPath **p_file_name_array,
ProPath **p_subdir_name_array);
Try your filter in Creo upfront. The header says you are okay. And check the listing_option value, this could be helpful.
But if this is a GUI issue I can’t help, PTC‘s windows kit is a overkill in my point of view 😉
Hi,
you have to ask PTC Support whether requested functionality is implemented. In standard interactive Creo session it is not available.