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 dont 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.
This very simple model creates the animation below, when simulating for 3 seconds:
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:
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 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.
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:
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. Lets 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. Lets correct that by setting the parameters.
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:
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.
Attachments: