Importing models from OnShape

From Rsewiki
Jump to: navigation, search

MATLAB 2017a+ includes functions to import 3D models from the browser based CAD modelling tool OnShape[1]. This functionality helps importing mechanical 3D objects for further analysis in a MATLAB/Simscape environment. This page will give an overview and a guide on how to import objects from OnShape to MATLAB.

For a quick overview of the two commands necessary to import from Onshape to Simscape can be seen here:

smexportonshape("link")
smimport(".xml")

The mechanical joints in OnShape and the joints in Simscape have different names but share attributes. An overview of OnShape joints and Simscape joints can be seen in the image below.

Multibody-onshape-blocks.png

In this guide the following model will be used. The 3D model can be accessed through here [2]. The model consists of multiple different joints. We will see how the in-built OnShape functions will automatically register and convert the joints in to the Simscape environment.

ModelOnshape-g1.png


In the right corner of the OnShape editing window a cube to control our 3D view can be seen. In the navigation bar at the top part of the screen two buttons are available [App Store] [Share]. Press the share button to find the link necessary for importing the model in to Simscape.

ModelOnshape-g2.png


A new window will appear. In this window 4 menus are available [Individuals] [Public] [Application] [Link]. Press the link button and copy the Document link: to your clipboard.

ModelOnshape-g4.png


Access your MATLAB terminal and run the following command to import the OnShape model to MATLAB:

ModelOnshape-g5.png


After running the code, a window should appear asking for OnShape credentials. Type in your OnShape account credentials. The import will happen as soon as your account is verified with OnShape.

ModelOnshape-g6.png


After verifying and importing the 3D model you should see 4 new files in your workspace. The files are the individual 3D objects with the .step file-extension and a file with a .xml file-extension describing how the individual models are assembled, their physical and material properties. The number of .step files will change with different projects, but there should always be 1 .xml file generated for every time you import a project.

ModelOnshape-g7.png


The last step is to run the following command to translate the .xml file to a Simscape object:

ModelOnshape-g8.png


The command automatically open a new Simulink window with the blocks from OnShape translated to Simscape

ModelOnshape-g9.png


Opening the Mechanics Explorer window will reveal the model in Simulink's own 3D object viewer. The explorer together with the Simscape block diagram can be used to verify that the model was imported correctly. This concludes the OnShape to Simscape import section.

ModelOnshape-g10.png

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox