Message Boards Message Boards

Move the model named "Generator" to class "ElectricalModels" in SM?

GROUPS:

Hi,

I need/want to move the model named "Generator" from class "GenericModels" to class "ElectricalModels". Of course I want all my models to get that I am moving it so that I do not have to re-create every model I ever created containing the model "Generator".

I suspect there is no way of doing this, but if so creating a new library is damn near impossible unless you know from beforehand what categories will be most practical for model grouping.

Thanks,

Martin

POSTED BY: Martin Nilsson
Answer
3 months ago

Hi,

unfortunately, you are correct that you cannot move a class and have all the references updated automatically. If you don't already have a package called "ElectricalModels", you could rename the original package to "ElectricalModels" and the references will change. But if you already have the "ElectricalModels" package, that of course isn't a possibility for you.

I have forwarded your suggestions to the developers working on the Model Center UI and hopefully this is something we can adress in the future.

Thanks, Patrik

POSTED BY: Patrik Ekenberg
Answer
3 months ago

Martin,

Until the developers address this issue, The best bet if you already have an ElectricalModels package is to move the component "Generator" to ElectricalModels. Open the models that use Generator one-by-one, switch to Modelica Text view and view the code and find and replace "GenericModels.Generator" with "ElectricalModels.Generator" using replace all. Next delete the Generator from GenericModels. This will break any remaining connections in your models that use the "GenericModels.Generator" component if you forgot any -- you can then edit any of the models you forgot to fix but the component will be missing in the digram view (but it will still be in the Modelica Text view).

It sounds painful but it actually is a pretty quick edit. You just need to open each model that uses the Generator and do a replace all.

Regards

POSTED BY: Neil Singer
Answer
3 months ago

Hi again,

actually, when reading your post I realized it can be even simpler. Since I am on Linux I do not need ModelCenter at all, in fact it is easier without.

A nifty combo of grep and sed will swiftly replace "GenericModels.Generator" with "ElectricalModels.Generator" in all files (i.e. models).

(One can do the same in windows since the bash shell is now available).

I'll try this tomorrow. And backup before beginning...

Regards

POSTED BY: Martin Nilsson
Answer
3 months ago

True. That will work well.

Make sure you copy the Generator to ElectricalModels first so when you open the models after your find/replace they can find the new Generator. Also, you are correct that it is a good idea to backup first!

Regards

POSTED BY: Neil Singer
Answer
3 months ago

Group Abstract Group Abstract