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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Load a model in a session

ddhini
15-Moonstone

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?

43 REPLIES 43
sjuraj
15-Moonstone
(To:ddhini)

You have not retrieved the part/asm. This code will open drawing in new activated window.

final String modelName = "test";

final String path = "c:/users/xxx/desktop/";

ModelDescriptor modelMD = pfcModel.ModelDescriptor_CreateFromFileName(

        path + modelName + ".prt");

ModelDescriptor drwMD = pfcModel.ModelDescriptor_CreateFromFileName(

        path + modelName + ".drw");

RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create();

rmo.SetAskUserAboutReps(false);

session.RetrieveModelWithOpts(modelMD, rmo);

Drawing drawing = (Drawing) session.RetrieveModelWithOpts(drwMD, rmo);

Window drwWin = session.CreateModelWindow(drawing);

drawing.Display();

drwWin.Activate();

ddhini
15-Moonstone
(To:ddhini)

Toolkit error is arising.. but don't know why it is arising.

sjuraj
15-Moonstone
(To:ddhini)

Try to solve it. I cant help you more. This works for me.

ddhini
15-Moonstone
(To:sjuraj)

Thank you so much for your help skvarka juraj

sjuraj
15-Moonstone
(To:ddhini)

no problem

ddhini
15-Moonstone
(To:sjuraj)

Its perfectly working .I failed to load my model thats why error arised.

   session = pfcGlobal.GetProESession();

    ModelDescriptor md1=null;

    md1 = pfcModel.ModelDescriptor_CreateFromFileName("C:\\Users\\350\\Desktop\\Mastermodels\\xxxx.prt");

    RetrieveModelOptions rmo1 = pfcSession.RetrieveModelOptions_Create();

    rmo1.SetAskUserAboutReps(false);

    session.RetrieveModelWithOpts(md1, rmo1);

    ModelDescriptor md=null;

    md = pfcModel.ModelDescriptor_CreateFromFileName("C:\\Users\\350\\Desktop\\Mastermodels\\xxxx.drw");

    RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create();

    rmo.SetAskUserAboutReps(false);

    Drawing draw=(Drawing)session.RetrieveModelWithOpts(md, rmo);

    draw.Display();

   Window window = session.GetModelWindow(draw);

    window.Activate();

ddhini
15-Moonstone
(To:sjuraj)

Hi ,I have a doubt.I want to open a drawing file and as well as its model file in a same session.Is it possible using Jlink.I did something but the file load in a single window only.Can you please guide me ?

sjuraj
15-Moonstone
(To:ddhini)

Create new window for model (part/asm) too and display the model. Then activate the window you want to be activated.

ddhini
15-Moonstone
(To:sjuraj)

Sorry ,I can't able to create a new window.

Window window=session.createmodelWindow(Model mod);

window .activate();

It loads the model in the existing window.

ddhini
15-Moonstone
(To:sjuraj)

ModelDescriptor md1=null;

  md1 = pfcModel.ModelDescriptor_CreateFromFileName("C:\\Users\\350\\Desktop\\Mastermodels\\xxxx.prt");

  RetrieveModelOptions rmo1 = pfcSession.RetrieveModelOptions_Create();

     rmo1.SetAskUserAboutReps(false);

  Model mdl=session.RetrieveModelWithOpts(md1, rmo1);

  mdl.Display();

  Window window= session.CreateModelWindow(mdl);

  window.Activate();

  ModelDescriptor md=null;

  md = pfcModel.ModelDescriptor_CreateFromFileName("C:\\Users\\350\\Desktop\\Mastermodels\\xxxx.drw");

  RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create();

  rmo.SetAskUserAboutReps(false);

  Drawing draw=(Drawing)session.RetrieveModelWithOpts(md, rmo);

  draw.Display();

  Window window1 = session.CreateModelWindow(draw);

  window1.Activate();

sjuraj
15-Moonstone
(To:ddhini)

Your code works for me well. You should use try-catch blocks to identify your problems. The exceptions are explained in HTML documentation.

ddhini
15-Moonstone
(To:sjuraj)

Thank you.....

ddhini
15-Moonstone
(To:sjuraj)

Here I want open the drawing file.not a part file .I tried something.Thanks for your valuable time.and Sorry to disturb you,

DrawingCreateOptions sd = com.ptc.pfc.pfcDrawing.DrawingCreateOptions.create();

  ModelDescriptor md1=null;

  md1 = pfcModel.ModelDescriptor_CreateFromFileName("C:\\Users\\350154\\Desktop\\Mastermodels\\xxxx.drw");

  RetrieveModelOptions rmo1 = pfcSession.RetrieveModelOptions_Create();

   rmo1.SetAskUserAboutReps(false);

  Model mdl=session.RetrieveModelWithOpts(md1, rmo1);

  ModelDescriptor md=null;

  Drawing draw=(Drawing)session.RetrieveModelWithOpts(md, rmo);

  draw.Display();

  Drawing drawingfile=session.CreateDrawingFromTemplate("New", null, md, sd);

Window win=session.CreateModelWindow(drawingfile);

  drawingfile.Display();

sjuraj
15-Moonstone
(To:ddhini)

You have not specitied template. You cant pass null as argument. You have to set DrawingCreateOption too. There is also example of using this method in doc example directory. Name of example file: pfcDrawingExamples.

Announcements


Top Tags