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?
Please sign in to leave a comment.
Use CloneModel in the context menu of the Project View or the CloneModel action.
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.
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.
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!
So this piece of code resolved my problem:
// Resolving references
ReferenceResolver refRes = new ReferenceResolver(copiedModel);
refRes.resolve();
newModels.add(copiedModel);
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?