# How to add CAD-structures in SystemModeler

**URL:** <https://community.wolfram.com/t/how-to-add-cad-structures-in-systemmodeler/3330>\
**Category:** Ideas\
**Tags:** engineering, geometry, system-modeler\
**Created:** [September 17, 2014, 2:20pm UTC](https://community.wolfram.com/t/how-to-add-cad-structures-in-systemmodeler/3330 "2014-09-17T14:20:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![karinh](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/karinh/32/4239_2.png) [@karinh](https://community.wolfram.com/u/karinh)\
**Post date:** [September 17, 2014, 2:20pm UTC](https://community.wolfram.com/t/how-to-add-cad-structures-in-systemmodeler/3330/1 "2014-09-17T14:20:13Z")

</div>

How can CAD-structures be added in _SystemModeler_ to make nice animations of the models? I will show a very easy example on how to do that.  
SystemModeler supports CAD in DXF, OBJ and STL file format. If you dont know how to create them by your own there are a lot of CAD examples downloadable on internet. But if you want to use them, make sure that it is ok with the creator of the CAD model.

For my model I will use components from the **Modelica.Mechanics.MultiBody** library. I assume that you have an interesting model that you just want to add CAD structures to, so I keep the model very simple.

 ![im1.png](https://global.discourse-cdn.com/wolfram/original/3X/e/8/e87a65ea1b42e7b9b15b293954619844e65e92d2.png)

This very simple model creates the animation below, when simulating for 3 seconds:

 ![im2.png](https://global.discourse-cdn.com/wolfram/original/3X/4/7/472e4b7e44fd323f840fd17831fe0271c430fbb5.png)

But now to the real task, we want a CAD shape instead of the sphere. For this we go back to ModelCenter and add **Modelica.Mechanics.MultiBody.Visualizers.FixedShape** in parallel with our body. The model now looks like:

 ![im3.png](https://global.discourse-cdn.com/wolfram/original/3X/4/2/4262c4043e450d83eca6b6154e2b8b01e40c9299.png)

We need to set a few parameters of the box to be able to show our CAD structure. I have downloaded a CAD example from [grabcad.com](http://grabcad.com) created by Adolf Rapp.  
We start by adding the filename to the parameter shapeType, and the length, width and height parameters of the box. This is done in the General tab.

 ![im4.png](https://global.discourse-cdn.com/wolfram/original/2X/1/1b302d9d8ec377848cb0a6499dec12ac2e2dc221.png)

We also set the animation parameter of the body to false, (animation = false), to avoid showing the sphere.  
Now we can make a first try to simulate the model. We got the animation:

 ![im5.png](https://global.discourse-cdn.com/wolfram/original/3X/0/7/076d004ddbdf5505b72c7a823fc58c9ab189f8ff.png)

This is obviously not correct, since the CAD model has been attached in the wrong direction. If we look a bit more at the animation we can see that we want the current y-axis of the CAD to be on the negative x-axis instead. And that the other direction should be on the negative z-axis. Lets correct that. The parameters lenghtDirection and widthDirection are used for that.  
We can see that the default value of these parameters are:

```
lengthDirection = {1, 0, 0}
widthDirection = {0, 1, 0}

```

We have concluded just by looking at the first animation that we want the current y-axis (widthDirection) to be negative x-axis, and the current x-axis (lengthDirection) to be on the negative z-axis. Lets correct that by setting the parameters.

 ![im6.png](https://global.discourse-cdn.com/wolfram/original/3X/d/e/de2dbc16bbe43cffcb67ccf46ecf7ef8a2e9f82b.png)

Please note that the widthDirection and lenghtDirections needs to be perpendicular vectors. If they are not the widthDirection is calculated as a perpendicular vector to the lengthDirection.  
When we have set these two parameters of the box, the animation looks like:

 ![im7.png](https://global.discourse-cdn.com/wolfram/original/3X/4/f/4f11e429ba7b370f35570db44530718e92c3b7b3.png)

Now the car is moving in the correct direction, and we are done with this simple example of how to add CAD structures to a _SystemModeler_ model.
