Note: The CAD assembly files of this case study require Pro/ENGINEER®.
The following example shows how to update a previously generated SimMechanics™ model with a new XML file exported after changes have been made to the original CAD assembly. The example starts with a double pendulum assembly.
For a general discussion of retranslation and update-import, see Retranslate CAD Assembly.
Look for the following seven CAD files of this case study in the SimMechanics Link examples folder.
|File Name||CAD File Type|
|Parts (main assembly)|
dpen assembly file and export it
into an XML file.
Export the assembly through the SimMechanics Link menu
of the CAD platform's menu bar. The result is an XML file called
To import the XML file and generate the SimMechanics model, you can either use the import dialog box or work with the full command at the MATLAB® command line.
Open the dialog box by entering
mech_import at the command
The alternative is to use the full command with specified import options:
This model results from the import step. The blocks are created at the top level.
With visualization enabled, you see this SimMechanics model with custom bodies defined by STL files exported when the XML file was exported.
If you want to import the assembly into a model subsystem, rather
than at the top level of a model, use the
mech_import command. (You can also use the
parallel options in the import dialog box.) For example, you can import
the assembly into a subsystem named Plant.
mech_import('dpen.xml','ImportMode',0,... 'ModelToImportInto','dpen_original',... 'SubsystemToImportInto','Plant');
You can change part properties in the original assembly and reimport the assembly, with those changes, to update the model. You can also make direct changes by hand to the original generated model and preserve those changes even as you update it with assembly changes.
In this example, you now cut out material from the links to make them lighter. You also connect joint and body sensors in the SimMechanics model to implement a controller. Now you want to update the SimMechanics model with changes from the assembly without undoing the additions you made by hand.
Change the double pendulum assembly and generate a new XML file from it.
pend part file and unsuppress
the Extrude2 feature to enable the hole in the parts. Do this by right-clicking
Extrude2 in the tree view and selecting Resume.
Save the part file.
Open and re-export the
file to obtain the new XML file, which is assumed to be named
In this example, you have separately made the following changes, by hand, to the original generated model, now renamed dpen_withsensors. These changes include insertion of a Joint Sensor, a Body Sensor, and two Scope blocks.
These are the properties of the PEND body before the update-import. PEND-1 has the same mass properties.
Before proceeding to the update-import from the updated CAD assembly, designate the manually added SimMechanics blocks that you want to retain and keep connected to the originally imported blocks. Right-click the sensor blocks and select the Retain connectivity to imported blocks option under the SimMechanics submenu. This option is selected by default.
Now update-import in such a way as to modify the PEND and PEND-1
body mass properties, without changing the manually added blocks and
connections. You can either use the import dialog box or the command
line with fully specified options to update the existing model. This
example uses the dialog box, opened by entering
the command line.
The dialog box is configured so that
the file imported to update the modified dpen_withsensors model. Because
the dialog box is set to update an existing model, the Update and Backup options
in the Advanced Options tab are now enabled.
Alternatively, if you want to use the command with fully specified options, enter:
mech_import('dpen_with_holes','ImportMode',1,... 'ModelToImportInto','dpen_withsensors','LayoutWithUpdate',1,... 'EnableIndvlBlkUpdCtrl',1,'BackupMode',0)
The updated model looks like the following. The sensors and Scopes are retained.
However, the PEND body properties are now different, because of the new holes in the parts. The PEND-1 mass properties are changed in the same way.
The updated bodies, displayed in SimMechanics visualization, appear differently as well, as determined by the new STL files exported from the updated assembly at the same time the new XML file was created.
The changes to an assembly that you can re-export are not limited to changes in existing parts (bodies). You can add or remove parts, re-export, then update-import an older version of the generated model with the changes.
In this example, in addition to the holes in the parts you previously made, you change the original assembly further by adding a new part (link) between the two original pendulum links, making the assembly a triple pendulum. This addition changes the topology of the assembly (the assembly's connectivity), beyond the property changes to the individual links.
To see such a changed assembly, open the
tpen assembly is a copy of the
with a link inserted. Export a new XML file, which is named
Update the existing dpen_withsensors model with the changes to the assembly. These are the required options in the import dialog box.
The Advanced Options tab shows important options selected for this example.
|Advanced Option||Effect of Option|
|Arrange all updated blocks||Selecting this option causes the importer to rearrange all
the imported and updated blocks.|
If cleared, the importer does not alter the layout of the existing blocks, whether updated or not, and places the newly imported blocks around the bounding box for the already existing blocks. In many cases, this means you have to rearrange the newly imported blocks by hand.
|Respect individual block update settings||Selecting this option preserves the associativity information specified on each block.|
|Backup mode||Using this pull-down menu allows you to choose how the model
is backed up during update. the backup options.|
By default, the backup copy of the model is created in the same folder as the model being updated.
The equivalent command line import command is:
mech_import('tpen.xml','ImportMode',1,... 'ModelToImportInto','dpen_withsensors','LayoutWithUpdate',1,... 'EnableIndvlBlkUpdCtrl',1,'BackupMode',0)
The block diagram shows that the part MID_PART inserted between the two links PEND and PEND-1. The sensors are retained. The properties of PEND and PEND-1 have been updated (to incorporate the holes that are now present). Because the Arrange all updated blocks option was selected, the blocks PEND and PEND-1 were moved to accommodate the block MID_PART and the joints Revolute2 and Revolute3.
The following block diagram shows the updated model that results when the Arrange all updated blocks option is cleared. The importer places the newly imported blocks around the bounding box of the existing blocks. The layout of the existing blocks is unchanged.
In circumstances where a set of assembly constraints imposes ambiguous restrictions on the motions of two parts, the SimMechanics Link exporter cannot resolve the constraint set into a moving joint. In such cases, it exports a Weld joint. If so, it is up to you to manually replace the Weld joint with the appropriate moving joint in the generated model. Even in situations where the exporter creates a moving joint, it might not reflect the degrees of freedom that you want, and you might want replace it with another. When you have replaced such joints in an imported model, and you want to update the model with changes from the CAD assembly, you generally want to retain the replacements you made manually.
Create a dpen_jointrep model in the following way.
Open the dpen_withsensors model and replace the Revolute joint between the two link bodies by a Planar joint that has some compliance in the plane perpendicular to the original revolute axis. Rename the Planar joint to Revolute with Compliance.
To update this model with changes to the link body properties, but to still retain the new Planar joint, right-click the Revolute with Compliance block and select the Retain connectivity to imported blocks option. It is selected by default.
Update this model with the new XML file that has changes to the properties of the links.
mech_import('dpen.xml','ImportMode',1,... 'ModelToImportInto','dpen_jointrep','LayoutWithUpdate',1,... 'EnableIndvlBlkUpdCtrl',1,'BackupMode',0)
The updated model retains the Revolute with Compliance joint.
You can update certain bodies while not updating other bodies with changes. Prevent a particular body from being updated during reimport by:
Right-clicking the body and selecting the Retain without updating properties option under the SimMechanics submenu.
Selecting the Respect individual block update settings option in the import dialog box.
If you use the full command instead, you need to set the
Clearing the Respect individual block update settings check box causes the importer to update all blocks, disregarding the update settings on the individual blocks.