Difference between revisions of "Tutorial: Creating Unity Assets with SOLIDWORKS"

From CEED Wiki
Jump to navigation Jump to search
(Template)
(Added the Solidworks Visualize (with textures) method.)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Check out this page for a description of different types of Pis and it's history: https://en.wikipedia.org/wiki/Raspberry_Pi
+
There are two main ways to export Unity Assets with Solidworks. Both methods have their pros and cons, but at the end of the day, the main consideration is if you want to have textures exported from Solidworks, or if you want more control over the computational weight of your asset (which will ultimately dictate the framerate at which your application will run).
  
== Setting up the OS on a Raspberry Pi ==
+
==Exporting without Textures==
When you first get a Rasperry Pi you need to setup the operating system on a micro SD card. You will download the ZIP for the operating system and either copy over the files to the SD card (NOOBS) or use an imager to do the installation (Raspbian).
+
The first method, without textures, gives you more control over how heavy the asset is.  
  
Here is a guide to help set up: https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up
+
===Exporting to STL===
  
Here is the official operating system with an installation guide: https://www.raspberrypi.org/downloads/raspbian/
+
*With SOLIDWORKS, open an assembly file. Under ''File'', select ''Save As'' and under ''Save as type'', select .STL
  
== Connecting to wifi networks on campus ==
+
[[File:Screenshot (7).png|center|thumb|364x364px|The ''File'' dropdown menu of SOLIDWORKS.]]
Connecting to wifi on campus can be difficult. You can connect to your phone or laptop if you turn on a hotspot, you can connect to eduroam by configuring it in the Pi or you can connect to an IOT (Internet Of Things) network called UOdevices by providing your Pi's MAC address.
 
  
=== Hotspot ===
+
*Press the ''Options'' button, and make sure that the option ''Save all components of an assembly in a single file'' is unchecked. You may also change the quality of the STL you export in this option dialogue. You should now have a .STL file for each assembly part. Place all the .STL files into a single folder.<br />
Setting up a hotspot with a PC: https://www.howtogeek.com/214080/how-to-turn-your-windows-pc-into-a-wi-fi-hotspot/
 
  
Setting up a hotspot with a MAC: https://www.howtogeek.com/214053/how-to-turn-your-mac-into-a-wi-fi-hotspot/
+
[[File:Screenshot (8).png|thumb|The SOLIDWORKS ''options'' menu to convert all of an assembly's components to .STL files. |alt=|center]]<br />
 +
===Importing .STL files into Blender===
 +
Open Blender, and delete the ''Camera, Cube,'' and ''Light'' on the right-hand side of the page by right-clicking on them, and pressing ''Delete''.   
 +
[[File:Screenshot (9).png|center|thumb|Deleting the default ''Light'' item in Blender. ]] 
 +
 
 +
Now, from the top left corner, press ''File, Import'' and ''Stl''. Navigate towards the folder that contains your .STL files. Once in the folder, CTRL + left-click all the .STL files, and finally click on ''Import STL.'' Once imported, the assembly will no longer have the textures or material appearances that were assigned to it in SOLIDWORKS. However, it is possible to assign new colors and/or textures to all the imported components using Blender. 
 +
[[File:Screenshot (10).png|center|thumb|Example of a drill press SOLIDWORKS assembly converted to a .blend file. The drill press' appearance was modified using Blender. ]]     
 +
 
 +
===Exporting to Unity===
 +
In Blender, from the top left corner, press ''File,'' and then ''Save''. Simply drag and drop the .blend file into Unity, where the assembly can now be used as an asset. If you wish to modify the asset, such as change its size or its appearance, simply open the .blend file and modify it using Blender.
  
Setting up a hotspot with a smart phone: https://www.pcmag.com/how-to/how-to-turn-your-phone-into-a-wi-fi-hotspot
+
==Exporting with Textures==
 +
The process of exporting with textures requires the use of Solidworks Visualize and a bit of setup, but allows for exporting with less steps. The quality (weight) of the exported asset is not directly obvious, however, as SW Visualize does not give an option for the quality of the export. According to the documentation, the quality of the polygonal file created by visualize on import is dictated by the properties used in Solidworks for the quality of any open document (go to ''Options (Gear)>Document Properties (Tab)>Image Quality'' to change this setting). This was however never properly verified.
  
=== Eduroam ===
+
===Setting Up Visualize===
You will need to go into the network settings of the Pi to configure the eduroam parameters.
+
Visualize will by default scale any parts that are imported if they are larger than a specified value. To change this, open Visualize and go Tools>Options>Import, and change the auto-scale options to the desired min and max quantities (this value is in millimeters).<br />
 +
[[File:Solidworks Visualize Options Pane.png|center|thumb|The import options pane for Solidworks Visualize]]
  
# Navigate to the folder etc/wpa_supplicant/ (cd /etc/wpa_supplicant/).
+
===Importing to Visualize===
# Open the wpa_supplicant.conf file (sudo nano wpa_supplicant.conf).
+
Once you are in Solidworks Visualize, you may simply navigate to ''File>Import''... and browse to your Solidworks part or assembly. The recommended settings for importing are:
# Add the lines below to the file, then save and close it.
 
# You may need to restart the Pi for the changes to take effect
 
  
network={
+
* Geometry:
 +
** Automatic part grouping (this is the same as Appearance/Layer when importing .SLDPRT and .SLDASM files)
 +
*** Retain structure will make the part exactly as it is in Solidworks, but the export from Visualize will be extremely heavy.
 +
** Do not snap to floor (unless the part wasn't modeled around the origin in Solidworks.
 +
** Instancing ON
 +
** (Part monitoring is optional but might lead to slow loading times)
 +
* Appearances:
 +
** Ignore Texture References OFF
 +
** Auto search for missing textures ON
 +
** Manual search for missing textures ON
 +
* Other options OFF
  
        ssid="eduroam"
+
=== Exporting to Unity-Readable Formats ===
 +
The preferred file types for importing to Unity are FBX or GLB. FBX files are typically more compact, though, while GLB/GLBF are more versatile, and are used in a multitude of programs other than Unity. GLB files contain the textures data in the file itself, such that you do not need to keep the model file with its textures.
  
        priority=1
+
* Navigate to ''File>Export>Export Project...''
 +
* Change the file type to your desired type
 +
* Save the file (it is suggested to create a folder within the project directory as all textures will also export as separate files.
  
        proto=RSN
+
You may now use these files in Unity. If you would like to modify the files in Blender, you may also do this with the aforementioned filetypes. To do this, follow the 'Importing .STL Files into Blender' steps from the 'Without Textures' section of this tutorial.
 
 
        key_mgmt=WPA-EAP
 
 
 
        pairwise=CCMP
 
 
 
        auth_alg=OPEN
 
 
 
        eap=PEAP
 
 
 
        identity="USERNAME" (your email)
 
 
 
        password="PASSWORD" (your uozone password)
 
 
 
}
 
 
 
=== UOdevices ===
 
This network covers STEM, CBY and SITE.
 
 
 
# You will need the MAC address of the Pi so that your device can be registered and approved to use the UOdevices network, here is how: https://www.raspberrypi-spy.co.uk/2012/06/finding-the-mac-address-of-a-raspberry-pi/
 
# Once you have the MAC, please send it to makerlab@uottawa.ca so it can be given to our IT department.
 
# When the MAC has been added, you will be able to connect to it in the same way as the Eduroam network with the ssid UOdevices and makerlab@uottawa.ca will also be able to give you the password.
 

Latest revision as of 22:38, 11 June 2021

There are two main ways to export Unity Assets with Solidworks. Both methods have their pros and cons, but at the end of the day, the main consideration is if you want to have textures exported from Solidworks, or if you want more control over the computational weight of your asset (which will ultimately dictate the framerate at which your application will run).

Exporting without Textures

The first method, without textures, gives you more control over how heavy the asset is.

Exporting to STL

  • With SOLIDWORKS, open an assembly file. Under File, select Save As and under Save as type, select .STL
The File dropdown menu of SOLIDWORKS.
  • Press the Options button, and make sure that the option Save all components of an assembly in a single file is unchecked. You may also change the quality of the STL you export in this option dialogue. You should now have a .STL file for each assembly part. Place all the .STL files into a single folder.
The SOLIDWORKS options menu to convert all of an assembly's components to .STL files.


Importing .STL files into Blender

Open Blender, and delete the Camera, Cube, and Light on the right-hand side of the page by right-clicking on them, and pressing Delete.

Deleting the default Light item in Blender.

Now, from the top left corner, press File, Import and Stl. Navigate towards the folder that contains your .STL files. Once in the folder, CTRL + left-click all the .STL files, and finally click on Import STL. Once imported, the assembly will no longer have the textures or material appearances that were assigned to it in SOLIDWORKS. However, it is possible to assign new colors and/or textures to all the imported components using Blender.

Example of a drill press SOLIDWORKS assembly converted to a .blend file. The drill press' appearance was modified using Blender.

Exporting to Unity

In Blender, from the top left corner, press File, and then Save. Simply drag and drop the .blend file into Unity, where the assembly can now be used as an asset. If you wish to modify the asset, such as change its size or its appearance, simply open the .blend file and modify it using Blender.

Exporting with Textures

The process of exporting with textures requires the use of Solidworks Visualize and a bit of setup, but allows for exporting with less steps. The quality (weight) of the exported asset is not directly obvious, however, as SW Visualize does not give an option for the quality of the export. According to the documentation, the quality of the polygonal file created by visualize on import is dictated by the properties used in Solidworks for the quality of any open document (go to Options (Gear)>Document Properties (Tab)>Image Quality to change this setting). This was however never properly verified.

Setting Up Visualize

Visualize will by default scale any parts that are imported if they are larger than a specified value. To change this, open Visualize and go Tools>Options>Import, and change the auto-scale options to the desired min and max quantities (this value is in millimeters).

The import options pane for Solidworks Visualize

Importing to Visualize

Once you are in Solidworks Visualize, you may simply navigate to File>Import... and browse to your Solidworks part or assembly. The recommended settings for importing are:

  • Geometry:
    • Automatic part grouping (this is the same as Appearance/Layer when importing .SLDPRT and .SLDASM files)
      • Retain structure will make the part exactly as it is in Solidworks, but the export from Visualize will be extremely heavy.
    • Do not snap to floor (unless the part wasn't modeled around the origin in Solidworks.
    • Instancing ON
    • (Part monitoring is optional but might lead to slow loading times)
  • Appearances:
    • Ignore Texture References OFF
    • Auto search for missing textures ON
    • Manual search for missing textures ON
  • Other options OFF

Exporting to Unity-Readable Formats

The preferred file types for importing to Unity are FBX or GLB. FBX files are typically more compact, though, while GLB/GLBF are more versatile, and are used in a multitude of programs other than Unity. GLB files contain the textures data in the file itself, such that you do not need to keep the model file with its textures.

  • Navigate to File>Export>Export Project...
  • Change the file type to your desired type
  • Save the file (it is suggested to create a folder within the project directory as all textures will also export as separate files.

You may now use these files in Unity. If you would like to modify the files in Blender, you may also do this with the aforementioned filetypes. To do this, follow the 'Importing .STL Files into Blender' steps from the 'Without Textures' section of this tutorial.