# Connection between two MultiBody SystemModels

**URL:** <https://community.wolfram.com/t/connection-between-two-multibody-systemmodels/18047>\
**Category:** Questions\
**Tags:** engineering, mathematica, system-modeler\
**Created:** [May 3, 2021, 5:24am UTC](https://community.wolfram.com/t/connection-between-two-multibody-systemmodels/18047 "2021-05-03T05:24:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bogdanudrea](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@bogdanudrea](https://community.wolfram.com/u/bogdanudrea)\
**Post date:** [May 3, 2021, 5:24am UTC](https://community.wolfram.com/t/connection-between-two-multibody-systemmodels/18047/1 "2021-05-03T05:24:26Z")

</div>

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.frame\_a,model2.c21.frame\_a} 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.frame\_a,c21.frame\_a} are not one of the expected ones: {}.

According to the Mathematica help page for **ConnectSystemModelComponents** at [https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html](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

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [May 3, 2021, 7:17am UTC](https://community.wolfram.com/t/connection-between-two-multibody-systemmodels/18047/2 "2021-05-03T07:17:09Z")

</div>

Bogdan,

You need to have a connector on each of your mode1 and model2 models if you want to connect them together. For example

```
comp1 = {"c11" \[Element] 
   "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "c12" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "frame1" \[Element] 
   "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn1 = {"c11.frame_b" \[DirectedEdge] "c12.frame_a", 
  "c11.frame_a" \[DirectedEdge] "frame1"}
ConnectSystemModelComponents["model1", comp1, conn1, 
 GraphLayout -> None]

comp2 = {"c21" \[Element] 
   "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "c22" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "frame2" \[Element] 
   "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn2 = {"c21.frame_b" \[DirectedEdge] "c22.frame_a", 
  "c21.frame_a" \[DirectedEdge] "frame2"}
ConnectSystemModelComponents["model2", comp2, conn2, 
 GraphLayout -> None]

```

You can connect them as you tried except your syntax of

```
"model1" \[Element] "Model"

```

makes no sense. You need to name an instance of the models you created:

```
compM = {"aa" \[Element] "model1", "bb" \[Element] "model2"}
connM = {"aa.frame1" \[DirectedEdge] "bb.frame2"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]

```

One other note, If you intend to use the multibody elements, you MUST have a World element in the top level model.

I hope this helps.

Regards,

Neil

---

<div class="post-metadata">

**Author:** ![bogdanudrea](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@bogdanudrea](https://community.wolfram.com/u/bogdanudrea)\
**Post date:** [May 3, 2021, 7:40am UTC](https://community.wolfram.com/t/connection-between-two-multibody-systemmodels/18047/3 "2021-05-03T07:40:40Z")

</div>

Neil,  
Thank you. Yes, it helps. I totally missed the fact that I have to instantiate the models that I created. The World component is at the top and not shown in this example.  
Best regards,  
B
