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

Load a model in a session

SOLVED
Seeker

Load a model in a session

I have a Model and i stored in my computer.Ex(C:\Desktop\load.prt)

In my proE session i involved a GUI.Where user can do some works.Here what i want is,I want to load a model that stored in C:\Desktop\load.prt  when user clicks the button .Can please any one tell me how to do this?

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Spectator

Re: Load a model in a session

RetrieveModel only puts model into session. However RetrieveModel ignores path. You have to use RetrieveModelWithOpts method instead. Note to use right path to your file. There is no such path as c:/desktop/xxx.prt. Path to desktop is always c:/<user_name>/desktop. This code will load model from path to session and than displays it in the new created window.

ModelDescriptor md = pfcModel.ModelDescriptor_CreateFromFileName("c:/users/<user_name>/desktop/xxx.prt");

RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create();

rmo.SetAskUserAboutReps(false);

Model model = session.RetrieveModelWithOpts(md, rmo);

Window window = session.CreateModelWindow(model);

model.Display();

window.Activate();

43 REPLIES
Spectator

Re: Load a model in a session

You can simply run macro and replace model name in macro string using method session.RunMacro

Voyager

Re: Load a model in a session

Use Retrieve model function to load the model in session

Use Model Descriptor to set the file name

You have to set the location as working directory

JKParthiban
Seeker

Re: Load a model in a session

Can you please explain it through coding?

Voyager

Re: Load a model in a session

Models char* _ProMdlRetrieve(wchar_t* FileName, int Type)

{

       char* msg;

       ProError Magizchi;

       ProMdlType modelType;

       switch(Type)

       {

       case 0:

              modelType = PRO_TYPE_UNUSED;

              break;

       case 1:

              modelType = PRO_ASSEMBLY;

              break;

       case 2:

              modelType = PRO_PART;

              break;

       case 3:

              modelType = PRO_DRAWING;

              break;

       case 4:

              modelType = PRO_MDL_3DSECTION;

              break;

       case 5:

              modelType = PRO_2DSECTION;

              break;

       case 6:

              modelType = PRO_LAYOUT;

       case 7:

              modelType = PRO_DWGFORM;

              break;

       case 8:

              modelType = PRO_MFG;

              break;

       case 9:

              modelType = PRO_REPORT;

              break;

       case 10:

              modelType = PRO_MARKUP;

              break;

       case  11:

              modelType = PRO_DIAGRAM;

              break;

       }

       ProMdl p_model;

       Magizchi = ProMdlRetrieve(FileName, modelType, &p_model);

       switch(Magizchi)

       {

       case PRO_TK_NO_ERROR:

              msg = "Model Retrieved";

              break;

       case PRO_TK_BAD_INPUTS:

              msg = "One or more of the input arguments are invalid";

              break;

       case PRO_TK_E_NOT_FOUND:

              msg = "The model was not found in the current directory";

              break;

       case PRO_TK_NO_PERMISSION:

              msg = "The function does not have permission to handle this model";

              break;

       }

       return msg;

}

Now call the method

_ProMdlRetrieve(FileName(wchar_t*), FileType(int))


You can also use out to hold the model data

JKParthiban
Seeker

Re: Load a model in a session

ModelDescriptor modeldesc = pfcModel.ModelDescriptor_Create(ModelType.MDL_PART, "C:\\Desktop\\xxxx.prt",null);

  Model model = session.RetrieveModel(modeldesc);

i coded something like this.

Voyager

Re: Load a model in a session

The method you have mentioned works in vb api & j-link.

I have mentioned toolkit. What is the error you'e getting?

JKParthiban
Spectator

Re: Load a model in a session

RetrieveModel only puts model into session. However RetrieveModel ignores path. You have to use RetrieveModelWithOpts method instead. Note to use right path to your file. There is no such path as c:/desktop/xxx.prt. Path to desktop is always c:/<user_name>/desktop. This code will load model from path to session and than displays it in the new created window.

ModelDescriptor md = pfcModel.ModelDescriptor_CreateFromFileName("c:/users/<user_name>/desktop/xxx.prt");

RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create();

rmo.SetAskUserAboutReps(false);

Model model = session.RetrieveModelWithOpts(md, rmo);

Window window = session.CreateModelWindow(model);

model.Display();

window.Activate();

Voyager

Re: Load a model in a session

Hi skvarka juraj

Retrieve Model does not ignore the path.

It loads the model to the session based on model descriptor.

If you have mentioned the path as pfcModelDescriptor.setPath = "Path Name"

then it considers the mentioned path otherwise it checks the model from workspace or working directory.

Retrieve Model With Options only used to ask User customized representation selection at the time of retrieval.

JKParthiban
Spectator

Re: Load a model in a session

I tryed it. RetrieveModel works only for working dir only. From the J-link guide:

guide.PNG