Importing models from OnShape: Difference between revisions

From Rsewiki
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
MATLAB 2017a+ includes functions to import 3D models from the browser based CAD modelling tool OnShape[https://www.onshape.com/]
MATLAB 2017a+ includes functions to import 3D models from the browser based CAD modelling tool OnShape[https://www.onshape.com/]. 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:


Overview of Simscape Multibody joints and the OnShape equivalent joints.
smexportonshape("link")
[[http://rsewiki.elektro.dtu.dk/images/0/0d/Multibody-onshape-blocks.png]]
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.
 
[[File:Multibody-onshape-blocks.png|1200px]]
 
In this guide the following model will be used. The 3D model can be accessed through here [https://cad.onshape.com/documents/bb8e51aedb9eed20ec779f03/w/1eb7a271d7114eaf981baf00/e/d5f12c27fed4289aae301e4c]. 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.
 
[[File:ModelOnshape-g1.png|700px]]
 
 
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|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.
 
[[File:ModelOnshape-g4.png|400px]]
 
 
Access your MATLAB terminal and run the following command to import the OnShape model to MATLAB:
 
[[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.
 
[[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.
 
[[File:ModelOnshape-g7.png|400px]]
 
 
The last step is to run the following command to translate the .xml file to a Simscape object:
 
[[File:ModelOnshape-g8.png|400px]]
 
 
The command automatically open a new Simulink window with the blocks from OnShape translated to Simscape
 
[[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.
 
[[File:ModelOnshape-g10.png|400px]]

Latest revision as of 10: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.

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.


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.


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.


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


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


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


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


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.