Skip to main content
1-Visitor
March 14, 2019
Solved

Retrieve model in toolkit

  • March 14, 2019
  • 3 replies
  • 9895 views

Hi all,

I try to retrieve model to assemble. I try to configure the model name in txt file.

ProStringToWstring(MLinkAToAssemble,MdAPart);
err = ProMdlRetrieve(MLinkAToAssemble,(ProMdlType)PRO_MDL_PART,(ProMdl*)&CompSolid);

I use the above code to retrieve model, but I get error PRO_TK_E_NOT_FOUND

whereas if i uses the model name directly I get the model in session

ProStringToWstring(MLinkAToAssemble,"TEST.PRT");
err = ProMdlRetrieve(MLinkAToAssemble,(ProMdlType)PRO_MDL_PART,(ProMdl*)&CompSolid);

Kindly throw some light

 

Regards,

Manjunath S

 

Best answer by Manjunath

@RPN @Ketan_Lalcheta  thanks for your suggestions

I came across few things in documentation. I would like to share with you

<li>This function accepts only strings only in the active 
 encoding of the Creo Parametric TOOLKIT application. Strings
 from other encodings may not be properly converted.

To handle this refer to UgUnicodeTranscoding.c in installation directory.

3 replies

1-Visitor
March 14, 2019

check with value of variable once (MDApart in your case). It should not have space or something extra characters. Also check once that wide char name holds proper value after conversion from text file variable value.

Manjunath1-VisitorAuthor
1-Visitor
March 14, 2019

@Ketan_Lalcheta  I have cross verified, herewith I have attached the image for reference

1-Visitor
March 14, 2019

I presume model is present into current working dir as it works with hard coded string. I have used this API and it works fine. Which Creo version you are having?

 

Additionally try with value as name only without extension once as you have already passed model type as part in second argument. If you don't wanna change value into text file and keep it as .prt only, use second argument as PRO_MDL_UNUSED.

 

HIH

Ketan

RPN
18-Opal
March 14, 2019

Get rid of the extension in your string!

Try this:

ProStringToWstring(MLinkAToAssemble,"TEST");

 

ProMdlRetrieve  (ProFamilyName name, 
ProMdlType    type,
                                 ProMdl       *p_handle); 
 
Type is given by ProMdlType!!
 
Windchill should work if you search for and you find it.
Manjunath1-VisitorAuthor
1-Visitor
March 15, 2019

@RPN  when I enter file name directly i can retrieve the model, but my requirement is model name have to be red from text file.

Manjunath1-VisitorAuthorAnswer
1-Visitor
March 15, 2019

@RPN @Ketan_Lalcheta  thanks for your suggestions

I came across few things in documentation. I would like to share with you

<li>This function accepts only strings only in the active 
 encoding of the Creo Parametric TOOLKIT application. Strings
 from other encodings may not be properly converted.

To handle this refer to UgUnicodeTranscoding.c in installation directory.

RPN
18-Opal
March 15, 2019

I don't believe that this is the problem, because you provide the input string.

 

str_type_table[] =
{
{(char *)"sec", PRO_2DSECTION},
{(char *)"prt", PRO_PART},
{(char *)"asm", PRO_ASSEMBLY},
{(char *)"drw", PRO_DRAWING},
{(char *)"mfg", PRO_MFG},
{(char *)"lay", PRO_LAYOUT},
{(char *)"frm", PRO_DWGFORM},
{(char *)"rep", PRO_REPORT},
{(char *)"mrk", PRO_MARKUP},
{(char *)"dgm", PRO_DIAGRAM},
{(char *)"???", PRO_TYPE_INVALID}
};

 

// You parse your file name

ProFilenameParse(sel_path, def_path, w_name, w_type, &version);

//Get the type (based on table above)

ProWstringToString(str, def_path);

ProUtilConfirmNameType(str, line, &type)

 

//Open the model you may need to change the dir 

ProMdlRetrieve(w_name, (ProMdlType)type, (ProMdl*)&comp);

 

Search at the sample folder.

 

In Tcl this is done in 2 min, check the section Files - Open, save, erase Creo files or the Windchill Section

 

 

Manjunath1-VisitorAuthor
1-Visitor
March 15, 2019

@RPN  in this case w_name if retrieved from Creo interface there wont be an issue, where as if its been retrieved from any other interface ex. text file then creo shows error. 

RPN
18-Opal
March 15, 2019

You can’t directly compare the Creo Interface with Toolkit. All model types are handled in one table without the need to have the 4 chars for the extension, instead you have an integer for the type.