Importing models from OnShape

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
 
Line 17: Line 17:
 
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.
 
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.
  
[[File:ModelOnshape-g2.png|300px]]
+
[[File:ModelOnshape-g2.png|400px]]
  
  
 
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.
 
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.
  
[[File:ModelOnshape-g4.png|700px]]
+
[[File:ModelOnshape-g4.png|400px]]
  
  
 
Access your MATLAB terminal and run the following command to import the OnShape model to MATLAB:
 
Access your MATLAB terminal and run the following command to import the OnShape model to MATLAB:
  
[[File:ModelOnshape-g5.png|700px]]
+
[[File:ModelOnshape-g5.png|400px]]
  
  
 
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.
 
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.
  
[[File:ModelOnshape-g6.png|700px]]
+
[[File:ModelOnshape-g6.png|400px]]
  
  
 
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.
 
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.
  
[[File:ModelOnshape-g7.png|700px]]
+
[[File:ModelOnshape-g7.png|400px]]
  
  
 
The last step is to run the following command to translate the .xml file to a Simscape object:
 
The last step is to run the following command to translate the .xml file to a Simscape object:
  
[[File:ModelOnshape-g8.png|700px]]
+
[[File:ModelOnshape-g8.png|400px]]
  
  
 
The command automatically open a new Simulink window with the blocks from OnShape translated to Simscape
 
The command automatically open a new Simulink window with the blocks from OnShape translated to Simscape
  
[[File:ModelOnshape-g9.png|700px]]
+
[[File:ModelOnshape-g9.png|400px]]
  
  
 
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.
 
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.
  
[[File:ModelOnshape-g10.png|700px]]
+
[[File:ModelOnshape-g10.png|400px]]

Latest revision as of 11:20, 9 August 2017

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