In Export a CAD Rigid Body, you create and export an assembly composed of a single part. 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 that include two cubes:

With no constraints, so that the cubes have the full six degrees of freedom relative to one another

Constrained in two different ways so as to produce the same result, a single prismatic (translational) DoF between them

Constrained so as to allow only a single revolute (rotational) DoF between them

Constrained so as to allow two prismatic (translational) DoFs between them

Constrained so as to allow relative spherical joint motion, with the two cubes separated by a constant nonzero distance

In different assemblies, the two cubes are constrained with different constraint combinations to create different relative DoFs between the cubes. In most cases, you can represent one set of DoFs with a large number of different combinations of constraints.

Look for the CAD assembly files of this study in the *smlink/smlinkdemos* directory.
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_` | Two cubes with a distance constraint |

The procedure for exporting a two-part assembly and generating SimMechanics models based on it is essentially the same for all the examples of this study.

To see a two-part assembly and export it into a Physical Modeling XML file:

Open the assembly,

`<assembly-name>.`

. The two parts are`ASSEMBLYFILETYPE`

`magic_cube-1`

and`magic_cube-2`

.Locate 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 the CAD assembly into Physical Modeling XML. The XML file is saved in your current working CAD folder.

You can import the Physical Modeling XML file into SimMechanics. SimMechanics interprets the file and generates a corresponding SimMechanics model. The new model is based on XML file structure and parameters. The CAD Import procedure requires access to SimMechanics.

Move or copy the XML file to a working MATLAB

^{®}folder. In this folder, open MATLAB.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 Block Structure of Two-Part Models. A set of Joints represents the DoFs between the two cubes.

In this study, all the models that you generate 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 fundamental root.*As in any generated CAD-based model, the four-block combination Machine Environment – Root Ground – Root Weld – Root Part represents the assembly fundamental root. The Root Part is a nonmoving, zero-mass/zero-inertia body.*The moving bodies.*The bodies representing the assembly 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 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 cube 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 treat unconstrained parts as free rigid bodies
with six mechanical degrees of freedom. To reduce the degrees of freedom
of a CAD part, and therefore the ways that part can move, you must *constrain* that
part. Applying a CAD constraint between two parts reduces the ways
the two parts can move with respect to each other. In a two-part CAD
assembly, one part is static relative 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 the assembly:

Open the assembly,

`sixDOF`

..`ASSEMBLYFILETYPE`

The cube parts have no constraints. Therefore, relative to one another, the cubes are unconstrained in their motion and have six relative DoFs.

Export this CAD assembly into the file,

`sixDOF.xml`

.

To generate a model based on the 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 express one translational degree of freedom. 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`

., and examine its CAD hierarchy.`ASSEMBLYFILETYPE`

Locate the two constraints on the two cubes.

Highlight the cylindrical constraint in the assembly. This constraint allows the two cubes to only slide along and rotate about the

*z*-axis running through the center of the parallel and concentric upper holes of each cube.Highlight the planar constraint 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. The constraint 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.

With these two constraints, 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.

**Cylindrical and Planar Constraints on Two
Cubes (SolidWorks)**

To see the second way of constraining the DoFs to produce a prismatic joint:

Open the assembly file,

`prismatic2`

., and examine its CAD hierarchy.`ASSEMBLYFILETYPE`

Locate the two constraints on the two cubes.

Highlight the first planar constraint 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 planar constraint 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. The constraint 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.

With these two constraints, 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 (SolidWorks)**

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`

., and examine its CAD hierarchy.`ASSEMBLYFILETYPE`

Locate the two constraints on the two cubes.

Highlight the cylindrical constraint 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 planar constraint in the assembly. This constraint allows the two cubes to slide along the

*x*-*y*plane, with the parallel sides sharing a common plane. The constraint 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.

With these two constraints, 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 the assembly:

Export the assembly as the file,

`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`

., and examine its CAD hierarchy.`ASSEMBLYFILETYPE`

Locate the two constraints on the two cubes.

Highlight the first planar constraint 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. The constraint 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 planar constraint 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.

With these two constraint, 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 the assembly:

Export the assembly as the file,

`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:

Open the assembly file,

spherical_spherical_massless_connector.

*ASSEMBLYFILETYPE*and examine its CAD hierarchy.

Locate the one constraint on the two cubes.

Highlight this distance-offset constraint. The two spherical pivot points occur one on each cube and mark the endpoints of the rigid massless connector. The cubes can move so that the distance between these two endpoints (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 (SolidWorks)**

To generate a model based on the assembly:

Export the assembly as a file,

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 Block Structure of Two-Part Models.

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.

Was this topic helpful?