cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to check part exist already in session/ or disk using Creo Toolkit?

AG_10775338
3-Visitor

How to check part exist already in session/ or disk using Creo Toolkit?

Hi, I'm new to Toolkit development, I'm using Creo Parametric 8
I'm developing a feature where to check Solid part with certain name say "X" already in an assembly if not I'm creating new part with API ProAsmcompMdlnameCreateCopy().
Problem is whenever there is part of with same name "X"(which is not assembled) in session or Current working directory it throws me an error PRO_TK_GENERAL_ERROR (-1).

I explored found API ProSessionMdlList() to get all model in session. This may be partially solves the problem.

Using loop I can avoid creating new part.

But I don't know how to check in Current working directory or any other specified location.

Please help me out.
If there is any better way for this problem, I highly appreciate it. 

Thanks, in advance!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
msteffke
13-Aquamarine
(To:AG_10775338)

The function ProFilesList will list files in a directory.  Heres a sample how I called it. 

 

  err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&file_list);
           err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&dir_list);
           strcpy(mystr, "*.prt,*.asm,*.lay");
           ProStringToWstring(w_line, mystr);
       err = ProFilesList(wname, w_line, PRO_FILE_LIST_ALL,  &file_list, &dir_list);
 
Or... you could just use the fact that your're getting a -1 as a return value, that could be your existence test.  (Its not documented that's what causes a general error, but seems to be what triggers that return.  its a reach but..)

View solution in original post

3 REPLIES 3
msteffke
13-Aquamarine
(To:AG_10775338)

The function ProFilesList will list files in a directory.  Heres a sample how I called it. 

 

  err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&file_list);
           err = ProArrayAlloc(0, sizeof(ProPath), 1, (ProArray*)&dir_list);
           strcpy(mystr, "*.prt,*.asm,*.lay");
           ProStringToWstring(w_line, mystr);
       err = ProFilesList(wname, w_line, PRO_FILE_LIST_ALL,  &file_list, &dir_list);
 
Or... you could just use the fact that your're getting a -1 as a return value, that could be your existence test.  (Its not documented that's what causes a general error, but seems to be what triggers that return.  its a reach but..)

@msteffke thanks for your answer, you are right Error returned in turn a check.

RPN
17-Peridot
17-Peridot
(To:AG_10775338)

extern

ProError

ProMdlnameInit ( ProMdlName name, ProMdlfileType type,ProMdl *p_mdl_handle);

 

Just Check for

PRO_TK_E_NOT_FOUND - Unable to find the required model.

Top Tags