| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimMechanics Link |
| Contents | Index |
| Learn more about SimMechanics Link |
| On this page… |
|---|
Modeling CAD and SimMechanics Degrees of Freedom Locating the Constraint Assembly Files Generating the Two-Part Models: Common Steps |
In Translating a CAD Part into a Body preceding, you create and export an assembly composed of a single part. CAD translation converts the part into a body, with a mass, an inertia tensor, and Body coordinate systems (CSs). Because there are no other parts in that CAD assembly, the SimMechanics body is welded to ground and has no degrees of freedom (DoFs). This lack of DoFs is not realistic for most assemblies.
This study presents a set of complete CAD assemblies with both parts and constraints and possessing DoFs. Each example assembly consists of two instances of the same part file, representing two identical cubes. The study shows how to find the required files, presents the essential steps for generating models from them, and describes the structure common to all the generated models. It ends with specific assembly cases.
In different assemblies, the two cubes are constrained with different constraint combinations to create different relative DoFs between the cubes. You can typically represent a set of DoFs with a large number of different constraint combinations. Each constraint combination here, in general, is not the unique way to create the corresponding set of DoFs. These assembly examples include:
Two cubes with no constraints, so that the cubes have the full six degrees of freedom relative to one another
Two cubes constrained in two different ways so as to produce the same result, a single prismatic (translational) DoF between them
Two cubes constrained so as to allow only a single revolute (rotational) DoF between them
Two cubes constrained so as to allow two prismatic (translational) DoFs between them
Two cubes constrained so as to allow relative spherical joint motion, with the two cubes separated by a constant nonzero distance
Locate the CAD assembly files for this study in the SimMechanics Link demos folder. The assemblies have the generic name <assembly-name>.ASSEMBLYFILETYPE. The cube part is in magic_cube.PARTFILETYPE.
| Assembly Name | Assembly Configuration |
|---|---|
| sixDOF | Two cubes with no constraints |
| prismatic1 | Two cubes with planar and cylindrical constraints |
| prismatic2 | Two cubes with planar constraints |
| revolute | Two cubes with planar and cylindrical constraints |
| inplane | Two cubes with planar constraints |
| spherical_spherical_ massless_connector | Two cubes with a distance constraint |
The steps for exporting a two-part assembly and generating SimMechanics models based on it are essentially the same for all the examples of this study.
To see a two-part assembly and export it into Physical Modeling XML:
Open the assembly <assembly-name>.ASSEMBLYFILETYPE. The two parts are magic_cube-1 and magic_cube-2.
In the CAD hierarchy, note any constraints imposed on the parts. These constraints define the relative DoFs between the parts.
Using the SimMechanics Link interface to your CAD platform, export this CAD assembly into Physical Modeling XML. The XML file is saved in your current working CAD folder.
You can generate a SimMechanics model based on this assembly.
Move or copy the XML file to a working MATLAB folder. Then open MATLAB in that folder.
At the command line, enter mech_import('<assembly_name>') to automatically generate a model, <assembly_name>.mdl, based on <assembly_name>.xml.
Open the subsystem. The blocks are arranged in the common structure described in About the Common Block Structure of the Two-Part Models: following. A set of Joints represents the DoFs between the two cubes.
All the models that you generate in this study each have eight blocks. From the example CAD assemblies, the models have a common structure because each assembly has a fundamental root and two moving parts:
The assembly's fundamental root. As in any generated CAD-based model, the four-block combination Machine Environment – Root Ground – Root Weld – Root Part represents the assembly's fundamental root. The Root Part is a nonmoving, zero-mass/zero-inertia body.
The moving bodies. The bodies representing the assembly's parts are magic_cube-1 and magic_cube-2.
The joints. In all the models, the first cube is connected by a Weld to Root Part and cannot move. The second cube is connected to RootPart by a Joint that represents the appropriate degrees of freedom (DoFs).
Depending on the DoFs in question in a particular assembly, CAD translation configures the Joint to represent different DoFs with combinations of prismatic, revolute, and spherical primitives. The second cube can move with respect to the first through the DoFs represented by the Joint.
Some of the blocks in the generated models are redundant. You can manually edit and simplify the models without changing their physical properties.
CAD platforms normally assume that two parts with no constraints between them have the complete six relative DoFs possessed by any rigid body relative to another body. You restrict the DoFs between parts by connecting them with constraints in the CAD assembly. Constraints restrict relative body motion and reduce the number of relative DoFs between body pairs. There is always one assembly part welded to ground.
The simplest assembly with two parts has no constraints between the parts. The parts can move with respect to one another with all six degrees of freedom (DoFs).
To see and export this assembly:
Open the assembly sixDOF.ASSEMBLYFILETYPE.
In the CAD hierarchy, the constraints (Mates) node has no entries. Therefore, relative to one another, the cubes are unconstrained in their motion and have six relative DoFs.
To generate a model based on this assembly:
At the MATLAB command line, enter mech_import('sixDOF') to generate a model, sixDOF.mdl.
Inspect the model. There are eight blocks.
The Six-DoF Joint represents the six DoFs between the two cubes with one spherical and three prismatic primitives.

In the following two assemblies, the two cubes are constrained to have only a single translational degree of freedom (DoF) between them. These assemblies illustrate two ways to accomplish this; you can experiment with other constraints to find more. In the translated SimMechanics models, this single DoF is a prismatic joint.
To see the first way of constraining the DoFs to produce a prismatic joint:
Open the assembly file prismatic1.ASSEMBLYFILETYPE and examine the CAD hierarchy.
Locate and expand the constraints (Mates) node. There are two constraints on the two cubes.
Highlight the first constraint, Concentric1. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes only to slide along and rotate about the z-axis running through the center of the parallel and concentric upper holes of each cube.
Highlight the second constraint, Coincident2. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide along the y-z plane, with the two sides marked "SimMechanics" sharing a common plane, representing two translational DoFs. It also allows the two cubes to rotate about the x-axis. The cubes are not allowed to rotate about any other axis, or to translate perpendicular to the y-z plane.
These two constraints mean that the two cubes can only slide along the z-axis common to the two upper concentric holes. The second constraint prevents rotation about this axis, leaving the whole assembly with only one translational DoF.
Planar and Cylindrical Constraints on Two Cubes

To see the second way of constraining the DoFs to produce a prismatic joint:
Open the assembly file prismatic2.ASSEMBLYFILETYPE and examine the CAD hierarchy.
Locate and expand the constraints (Mates) node. There are two constraints on the two cubes.
Highlight the first constraint, Coincident2. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide along the y-z plane, with the two sides marked "SimMechanics" sharing a common plane, representing two translational DoFs. It also allows the two cubes to rotate about the x-axis. The cubes are not allowed to rotate about any other axis, or to translate perpendicular to the y-z plane.
Highlight the second constraint, Coincident3. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide along the x-z plane, with the two sides marked "The MathWorks" sharing a common plane, representing two translational DoFs. It also allows the two cubes to rotate about the y-axis. The cubes are not allowed to rotate about any other axis, or to translate perpendicular to the x-z plane.
These two constraints mean that the two cubes can only slide along the z-axis common to the two planes y-z and x-z, leaving the whole assembly with only one translational DoF.
Two Planar Constraints on Two Cubes

To create models from the assemblies:
Export the two assemblies into the XML files prismatic1.xml and prismatic2.xml.
Copy or move them to a MATLAB working folder. At the MATLAB command line, generate SimMechanics models using mech_import.
In both models, the assemblies are translated into block diagrams of eight blocks each. The Prismatic Joint represents the single translational DoF between the two cubes with one prismatic primitive along the z-axis.
In the following assembly, the two cubes are constrained to have only a single rotational degree of freedom (DoF) between them. In the translated SimMechanics model, this single DoF is a revolute joint.
To see an assembly with one rotational DoF:
Open the assembly file revolute.ASSEMBLYFILETYPE and examine the CAD hierarchy.
Locate and expand the constraints (Mates) node. There are two constraints on the two cubes.
Highlight the first constraint, Concentric1. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide along and rotate about the z-axis running through the center of the parallel and concentric upper holes of each cube.
Highlight the second constraint, Coincident1. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide along the x-y plane, with the parallel sides sharing a common plane. It also allows the two cubes to rotate about the z-axis. The cubes are not allowed to rotate about any other axis, or to translate perpendicular to the x-y plane.
These two constraints mean that the two cubes can only rotate about the z-axis orthogonal to the x-y plane, leaving the whole assembly with only one rotational DoF.
To generate a model based on this assembly:
Export the assembly as revolute.xml. Copy or move it to a MATLAB working folder.
At the MATLAB command line, generate a SimMechanics model using mech_import.
The assembly is translated into a block diagram of eight blocks. The Revolute Joint represents the single rotational DoF between the two cubes with one revolute primitive about the z-axis.
In the following assembly, the two cubes are constrained to have only two translational degrees of freedom (DoFs) between them. In the translated SimMechanics model, these two DoFs are two prismatic joints.
To see an assembly with two translational DoFs:
Open the assembly file inplane.ASSEMBLYFILETYPE and examine the CAD hierarchy.
Locate and expand the constraints (Mates) node. There are two constraints on the two cubes.
Highlight the first constraint, Coincident2. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide along the y-z plane, with the two sides marked "SimMechanics" sharing a common plane. It also allows the two cubes to rotate about the x-axis. The cubes are not allowed to rotate about any other axis, or to translate perpendicular to the y-z plane.
Highlight the second constraint, Parallel1. The constraint geometry is highlighted in the assembly. This constraint allows the two cubes to slide parallel to the x-z plane, with the two sides marked "The MathWorks'' parallel but not necessarily in the same plane. It also allows the two cubes to translate perpendicular to the x-z plane and to rotate about the y-axis. The cubes are not allowed to rotate about any other axis.
These two constraints mean that the two cubes can only slide in the y-z plane, leaving the whole assembly with only two translational DoFs.
To generate a model based on this assembly:
Export the assembly as inplane.xml. Copy or move it to a MATLAB working folder.
At the MATLAB command line, generate a SimMechanics model using mech_import.
The assembly is translated into a block diagram of eight blocks. The In-Plane Joint represents the two translational DoFs between the two cubes with two prismatic primitives, along the y-axis and the z-axis.
In the following assembly, the two cubes are constrained to have six rotational degrees of freedom (DoFs) between them, represented by two spherical primitives. The spherical primitives pivot independently about two pivot points at a fixed relative distance. In the translated SimMechanics model, a spherical-spherical massless connector represents these six DoFs.
To see an assembly with three rotational DoFs separated from three other rotational DoFs:
spherical_spherical_massless_connector.ASSEMBLYFILETYPE
and examine the CAD hierarchy.
Locate and expand the constraints (Mates) node. There is one constraint on the two cubes.
Highlight constraint Distance1. The two spherical pivot points are highlighted as small red or green squares, one on each cube. These points are the endpoints of the rigid massless connector. The cubes can move such that the distance between these two points (the length of the massless connector) does not change. The constraint allows the two cubes to pivot independently about their connector endpoints.
Distance Constraint on Two Cubes

To generate a model based on this assembly:
spherical_spherical_massless_connector.xml
Copy or move it to a MATLAB working folder.
At the MATLAB command line, generate a SimMechanics model using mech_import.
The assembly is translated into a block diagram of eight blocks, arranged in the common structure described in About the Common Block Structure of the Two-Part Models: preceding.
The Spherical-Spherical massless connector Joint block represents the two spherical primitives, each with three rotational DoFs, independently pivoting at each end of the massless, rigid connector connecting the two cubes.
![]() | Translating a CAD Part into a Body | Updating and Retranslating a CAD Pendulum | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |