Dear Colleagues,
I am trying to connect a set of SystemModels that I generated programmatically in Mathematica. I am interested in MultiBody models and I haven't tried other types of models. I am failing gloriously and I have spent a good part of the day reading the online help pages and performing a lot of trial and error. Here's a simplified example
First model called "model1"
comp1 = {"c11" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape",
"c12" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape"}
conn1 = {"c11.frame_b" \[DirectedEdge] "c12.frame_a"}
ConnectSystemModelComponents["model1", comp1, conn1, GraphLayout -> None]
Second model called "model2"
comp2 = {"c21" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape",
"c22" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape"}
conn2 = {"c21.frame_b" \[DirectedEdge] "c22.frame_a"}
ConnectSystemModelComponents["model2", comp2, conn2, GraphLayout -> None]
Model'o'models - failure
(*"Model" found by trial error. Is it needed, is it correct? At least Mathematica don't complain about it*)
compM = {"model1" \[Element] "Model", "model2" \[Element] "Model"}
connM = {"model1.c11.frame_a" \[DirectedEdge] "model2.c21.frame_a"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]
The error message is
ConnectSystemModelComponents::cnf: Connectors {model1.c11.framea,model2.c21.framea} are not one of the expected ones: {}.
I have also tried
connM = {"c11.frame_a" \[DirectedEdge] "c21.frame_a"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]
that gives a similar error message:
ConnectSystemModelComponents::cnf: Connectors {c11.framea,c21.framea} are not one of the expected ones: {}.
According to the Mathematica help page for ConnectSystemModelComponents at https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html
The compi can be a SystemModel object, a full model name string or a shortened model name accepted by SystemModel.
The error seems to come from the connectors of each model so the question is What type of connectors should I use?
Last but not least, I have also tried something a bit more sophisticated by introducing a MultoBody Interface component
comp1 = {"c11" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape",
"c12" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape",
"if1" \[Element] "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn1 = {"c11.frame_a" \[DirectedEdge] "if1",
"c11.frame_b" \[DirectedEdge] "c12.frame_a"}
ConnectSystemModelComponents["model1", comp1, conn1]
comp2 = {"c21" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape",
"c22" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape",
"if2" \[Element] "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn2 = {"c21.frame_a" \[DirectedEdge] "if2",
"c21.frame_b" \[DirectedEdge] "c22.frame_a"}
ConnectSystemModelComponents["model2", comp2, conn2]
compM = {"model1" \[Element] "Model", "model2" \[Element] "Model"}
connM = {"model1.if1" \[DirectedEdge] "model2.if2"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]
That gives the same type of error.
I have posted this question on StackExchange as well.
Thank you.
B