Generate SimMechanics Second Generation model from SimMechanics Import XML file


H = smimport('filename')
H = smimport('filename', 'ModelName', 'modelname')


H = smimport('filename') imports SimMechanics™ XML file filename.xml into a new Simulink™ model with the same name. SimMechanics generates the new model according to XML file specification, adding and connecting any required blocks. For CAD-generated XML files, the new model represents a CAD assembly.

filename is a string specifying the XML file name. This string must be a valid model name, using any combination of letters, digits, and underscores such that the first character is a letter and the length of the string is smaller than namelengthmax. If filename is invalid, SimMechanics generates a valid name based on filename.

If a model with the same name is open,smimport returns a warning and appends an integer to filename in order to create a unique model name. If a model with the same name exists in the MATLAB workspace or path, smimport returns a warning asking you to change the model name.

filename supports path specification relative to the MATLAB working directory. Alternatively, filename can contain the full path to the corresponding XML file. In the absence of a path, smimport searches for filename inside the MATLAB path.

By default, smimport assumes filename refers to an XML file in the MATLAB workspace or path. filename does not require an explicit XML extension. If filename is not an XML file, or if it is not in the MATLAB workspace or path, smimport returns an error.

H = smimport('filename', 'ModelName', 'modelname') imports XML file filename into a new SimMechanics model with name modelname.

Input Arguments


String specifying input XML file name. Replace filename with the XML file name you want to import. The .xml extension is optional.

This input is required.

Default: ''

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.


String specifying generated SimMechanics model name.

This input is optional.

Default: ''


Use the smimport command to automatically generate a SimMechanics model with default or custom names.

Import Robot Assembly with Default Name

SimMechanics provides a SimMechanics Import XML file that you can use to import a robot arm model. The file, named sm_robot.xml, provides SimMechanics the data it needs to automatically generate the model. You can generate a SimMechanics Import XML file from a supported CAD platform using the SimMechanics Link utility.

To import the sm_robot assembly into SimMechanics:

  1. At the command line, enter


  2. Save the file in a convenient folder.

Import Robot Assembly with Custom Name

You can specify a custom model name directly at the MATLAB® command line. You accomplish this task by including a ModelName argument in the smimport command. For example, to assign the robot_arm name to the sm_robot assembly, at the MATLAB command line, enter:

smimport('sm_robot', 'ModelName', 'robot_arm');

SimMechanics automatically generates a robot arm model with the robot_arm name.

More About

collapse all


  • smimport provides CAD integration with SimMechanics. Use SimMechanics Link™ to generate a valid SimMechanics XML file from SolidWorks™, Creo™ (Pro/Engineer™), or AutoCAD Inventor™. Then, use smimport to generate a corresponding SimMechanics model.

See Also


Was this topic helpful?