Copying Model

Hi all,

I want to create the copy of the model but the new copied model still hold references to the nodes from the older model and not from the newer model. Is there way to resolve this issue?
Is there a proper method or something MPS to copy models?

0
6 comments

Use CloneModel in the context menu of the Project View or the CloneModel action.

 

0

Thanks for the reply. I saw the CloneModel action but didn't know how to use it. It would be really helpful if you could give a liner code example of it! Thanks again.

0

If you do not want to invoke the action from the UI, you should take inspiration from the code in NewModelDialog and modify it for your own needs. Especially the doOKAction() method is worth checking out, I think.

1

Hi Vaclav,

I looked into the source code of doOkAction() of NewModelDialog but it didn't seem to resolve references either.

In fact when I use Clone Model action from MPS UI to copy the model the references in the newly created model created by Clone Model action are also unresolved. Unless you press F5 or run automatic reference resolve quick fix.

But MPS does seem to have automatic reference resolve fix as references are automatically resolved when F5 is pressed or automatic reference resolve quick fix box is checked in the settings. Do you know where this functionality is implemented in MPS? May be i could get some inspiration from there.

Thanks!

0

So this piece of code resolved my problem:

// Resolving references
ReferenceResolver refRes = new ReferenceResolver(copiedModel);
refRes.resolve();
newModels.add(copiedModel);

1

Hi Hassan Qayyum,
      I am unable to find the ReferenceResolver class. I am seeing only an interface named ReferenceResolver.
     How do you get ReferenceResolver ?  

     Can you tell the package of the ReferenceResolver class? 

0

Please sign in to leave a comment.